Trouble with a own Cron

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');
        }
    }
}
 
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');
        }
    }
}
 
  • Like
Reactions: DSF
Top Bottom