AndyB
Well-known member
In an add-on called Auto delete I would like to have a cron entry delete a thread. When I run this code from the cron entry:
I get the following error:
Which code do we need in order to delete a thread in a Cron entry?
Thank you.
PHP:
foreach ($threads AS $k => $v)
{
$threadId = $v['thread_id'];
$type = 'hard';
$reason = '';
$finder = \XF::finder('XF:Thread');
$thread = $finder
->where('thread_id', '=', $threadId)
->fetch();
$deleter = \XF::app()->service('XF:Thread\Deleter', $thread);
$deleter->delete($type, $reason);
}
I get the following error:
Code:
An exception occurred: [TypeError] Argument 2 passed to XF\Service\Thread\Deleter::__construct() must be an instance of XF\Entity\Thread, instance of XF\Mvc\Entity\ArrayCollection given, called in /home/southbay/public_html/forums200/src/XF/Container.php on line 274 in src/XF/Service/Thread/Deleter.php on line 19
Which code do we need in order to delete a thread in a Cron entry?
Thank you.