Fixed Delete Bug

sip

Active member
Affected version
2.0.0 RC1
Steps to reproduce

1. Add a thread
2. Reply to that thread
3. Select both reply and the thread
4 Delete
5. Delete Permanently.

Errror as on screen is:

Code:
LogicException: Attempted to set 'reply_count' on a deleted entity in src/XF/Mvc/Entity/Entity.php at line 519
XF\Mvc\Entity\Entity->set() in src/XF/Mvc/Entity/Entity.php at line 502
XF\Mvc\Entity\Entity->__set() in src/XF/Entity/Thread.php at line 672
XF\Entity\Thread->postRemoved() in src/XF/Entity/Post.php at line 688
XF\Entity\Post->_postDelete() in src/XF/Mvc/Entity/Entity.php at line 1471
XF\Mvc\Entity\Entity->delete() in src/XF/Service/Post/Deleter.php at line 95
XF\Service\Post\Deleter->delete() in src/XF/InlineMod/Post/Delete.php at line 33
XF\InlineMod\Post\Delete->applyToEntity() in src/XF/InlineMod/AbstractAction.php at line 87
XF\InlineMod\AbstractAction->applyInternal() in src/XF/InlineMod/AbstractAction.php at line 80
XF\InlineMod\AbstractAction->apply() in src/XF/Pub/Controller/InlineMod.php at line 131
XF\Pub\Controller\InlineMod->actionPerform() 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 1852
XF\App->run() in src/XF.php at line 328
XF::runApp() in index.php at line 13

Tried many times and the error reproduces.
Deleting individually works fine.
 
Soft delete works fine.
Hard delete after soft delete also works fine
Hard Delete individually also works fine.
Problem comes when we select all in the thread and then do hard delete.
 
If you click again, the two posts will be deleted but you get after it an error message “The requested thread could not be found” insted of redirecting to forum threads list.
 
Thanks - this has been sorted for the next release.

If a "first post" of a thread has already been deleted, then all other posts in that thread will have already been deleted, hence the error. We can just skip all posts belonging to a thread if we're hard deleting and the thread itself was already deleted.
 
Back
Top Bottom