Lack of interest If the cron task file do not exist, improve the error message

Rigel Kentaurus

Well-known member
#1
I have noticed that when I run a scheduled task, if the file is no longer there, it does not complain at all, but just gives me a "Task finished successfully" kind of message

It happened to me that I was reuploading some files and one was missing. I even ran the cron job manually and I only noticed because it was unusually fast. Probably a message stating that the file containing the cron job is not found would be better.
 
R

ragtek

Guest
#2
That's what i'm using in my dev tools to make debugging easier:

Class XenForo_Model_Cron

PHP:
    public function runEntry(array $entry)
    {
        if (XenForo_Application::autoload($entry['cron_class']) && method_exists($entry['cron_class'], $entry['cron_method']))
        {
            call_user_func(array($entry['cron_class'], $entry['cron_method']));
            return true;
        }
        else {
            $error = 'Cron file ' . $entry['cron_class'] . ' or method ' . $entry['cron_method'] . ' doesn\'t exist';
            XenForo_Helper_File::log('cronerrors', $error);
            return false;
        }
    }
instead of
PHP:
    /**
    * Runs the given entry if possible.
    *
    * @param array $entry Info about cron entry
    */
    public function runEntry(array $entry)
    {
        if (XenForo_Application::autoload($entry['cron_class']) && method_exists($entry['cron_class'], $entry['cron_method']))
        {
            call_user_func(array($entry['cron_class'], $entry['cron_method']));
        }
    }
and in XenForo_ControllerAdmin_Cron
PHP:
public function actionRun()
    {
        $this->_checkCsrfFromToken($this->_input->filterSingle('_xfToken', XenForo_Input::STRING));

        $entryId = $this->_input->filterSingle('entry_id', XenForo_Input::STRING);
        $entry = $this->_getCronEntryOrError($entryId);

        if ($this->_getCronModel()->runEntry($entry)) // TODO: capture output or something more useful
        {
            return $this->responseMessage(new XenForo_Phrase('cron_entry_run_successfully'));

        }
        else {
            throw new XenForo_Exception('no valid cronfile', true);
        }
    }
 
Top