XF 2.0 Attempted to set 'delete_user_id' on a deleted entity

Scandal

Well-known member
I have this custom code on my addon which soft deletes a thread:
Code:
            // now delete
            $userRepo = \XF::app()->repository('XF:User');
            $deleter_userinfo = $userRepo->getUserByNameOrEmail(\XF::app()->options()->sc_deleter_username);
            $deleter = \XF::app()->service('XF:Thread\Deleter', $threadinfo);
            $deleter->setUser($deleter_userinfo);
            $deleter->delete('soft', 'This is a reason');

The issue is that some times I get this error:
PHP:
LogicException: Attempted to set 'delete_user_id' on a deleted entity in src/XF/Mvc/Entity/Entity.php at line 522
XF\Mvc\Entity\Entity->set() in src/XF/Mvc/Entity/Entity.php at line 505
XF\Mvc\Entity\Entity->__set() in src/XF/Entity/DeletionLog.php at line 26
XF\Entity\DeletionLog->setFromUser() in src/XF/Entity/Thread.php at line 995
XF\Entity\Thread->softDelete() in src/XF/Service/Thread/Deleter.php at line 67
XF\Service\Thread\Deleter->delete() in src/addons/Scandals/****/Admin/Controller/AdminCP.php at line 153
Scandals\****\Admin\Controller\AdminCP->sc_****() in src/addons/Scandals/****/Admin/Controller/AdminCP.php at line 593
Scandals\****\Admin\Controller\AdminCP->actionFastActions() in src/XF/Mvc/Dispatcher.php at line 249
XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 88
XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 41
XF\Mvc\Dispatcher->run() in src/XF/App.php at line 1931
XF\App->run() in src/XF.php at line 329
XF::runApp() in admin.php at line 13
Any idea?
I checked the files but didn't achieve to fix the bug. It seems all ok to me.
It is on xF2.0.
 
Back
Top Bottom