1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

Discussion in 'Closed Suggestions' started by Rigel Kentaurus, Jun 26, 2011.

  1. Rigel Kentaurus

    Rigel Kentaurus Well-Known Member

    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.
     
    ragtek likes this.
  2. ragtek

    ragtek Guest

    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);
            }
        }
     
    Rigel Kentaurus likes this.

Share This Page