Fixed Addon Cronjob is being called, even when the addon is deactivated

xf_phantom

Well-known member
XenForo is calling addon cronjobs from all addons.It doesn't evaluate if the addon is deactivated, which icausing many bad side effects
 
Hmm, ATM i'm not sure if i reported this too early
It seems that there's another problem because xf is checking if addon.active = 1
PHP:
public function getMinimumNextRunTime()
    {
        $nextRunTime = $this->_getDb()->fetchOne('
            SELECT MIN(entry.next_run)
            FROM xf_cron_entry AS entry
            LEFT JOIN xf_addon AS addon ON (entry.addon_id = addon.addon_id)
            WHERE entry.active = 1
                AND (addon.addon_id IS NULL OR addon.active = 1)
        ');
        if ($nextRunTime)
        {
            return $nextRunTime;
        }
        else
        {
            return 0x7FFFFFFF; // no entries to run, return time well in future
        }
    }
&&
PHP:
    public function getCronEntriesToRun($currentTime = null)
    {
        $currentTime = ($currentTime === null ? XenForo_Application::$time : $currentTime);

        return $this->fetchAllKeyed('
            SELECT entry.*
            FROM xf_cron_entry AS entry
            LEFT JOIN xf_addon AS addon ON (entry.addon_id = addon.addon_id)
            WHERE entry.active = 1
                AND entry.next_run < ?
                AND (addon.addon_id IS NULL OR addon.active = 1)
            ORDER BY entry.next_run
        ', 'entry_id', $currentTime);
    }
 
Ok, i've found the problem

Another admin called the cronjobs from the acp / cronlist.

The "problem" is, that the list shows ALL available crons, even if the addon is disabled.
And when you call it, it doesn't check if the addon is active



What about showing a confirmation message before the cron is being called, if the addon or cron are deactivated?
 
Last edited:
Back
Top Bottom