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

Trouble with a own Cron

Discussion in 'Troubleshooting and Problems' started by DSF, Apr 17, 2012.

  1. DSF

    DSF Well-Known Member

    I get this error for a xf-Cron

    Fatal error: Using $this when not in object context in .......

    What is wrong her?
    I can't find the error :(

    PHP:
    <?php
     
    class XenForo_CronEntry_TestDeleteThreads
    {
        public static function 
    runTestDeleteThreads()
        {
            
    $deleteDate strtotime('-24 hours');
     
            
    $threads $this -> _getDb() -> fetchAll ("
                SELECT * FROM xf_thread
                WHERE user_id = 28
                AND node_id = 8
                AND reply_count = 0
                AND last_post_date < ?"
    $deleteDate);
     
            foreach (
    $threads AS $thread)
            {
                
    $this->getModelFromCache('XenForo_Model_Thread')->deleteThread($thread['thread_id'], 'hard');
                
    XenForo_Helper_Cookie::clearIdFromCookie($thread['thread_id'], 'inlinemod_threads');
            }
        }
    }
     
  2. Onimua

    Onimua Well-Known Member

    Try this instead.
    PHP:
    <?php
     
    class XenForo_CronEntry_TestDeleteThreads
    {
        public static function 
    runTestDeleteThreads()
        {
            
    $deleteDate strtotime('-24 hours');
     
            
    $threads XenForo_Application::getDb()->fetchAll ("
                SELECT * FROM xf_thread
                WHERE user_id = 28
                AND node_id = 8
                AND reply_count = 0
                AND last_post_date < ?"
    $deleteDate);
     
            foreach (
    $threads AS $thread)
            {
                
    XenForo_Model::create('XenForo_Model_Thread')->deleteThread($thread['thread_id'], 'hard');
                
    XenForo_Helper_Cookie::clearIdFromCookie($thread['thread_id'], 'inlinemod_threads');
            }
        }
    }
     
    DSF likes this.
  3. DSF

    DSF Well-Known Member

    Now it's perfect!
    My mistake.
    Many thanks to you. (y)
     

Share This Page