Fixed Uncaught race condition with profile posts deletion: "Duplicate entry 'profile_post-***' for key 'xf_deletion_log.PRIMARY'"

nocte

Well-known member
Licensed customer
Affected version
2.3.12
From my error logs:

Code:
XF\Db\DuplicateKeyException: MySQL query error [1062]: Duplicate entry 'profile_post-5354653' for key 'xf_deletion_log.PRIMARY' src/XF/Db/AbstractStatement.php:225
Generated by: *** 18.8.2026 at 06:53
Stack trace
INSERT  INTO `xf_deletion_log` (`content_type`, `content_id`, `delete_user_id`, `delete_username`, `delete_reason`, `delete_date`) VALUES (?, ?, ?, ?, ?, ?)
------------

#0 src/XF/Db/Mysqli/Statement.php(207): XF\Db\AbstractStatement->getException('MySQL query err...', 1062, '23000')
#1 src/XF/Db/Mysqli/Statement.php(83): XF\Db\Mysqli\Statement->getException('MySQL query err...', 1062, '23000')
#2 src/XF/Db/AbstractAdapter.php(96): XF\Db\Mysqli\Statement->execute()
#3 src/XF/Db/AbstractAdapter.php(219): XF\Db\AbstractAdapter->query('INSERT  INTO `x...', Array)
#4 src/XF/Mvc/Entity/Entity.php(1578): XF\Db\AbstractAdapter->insert('xf_deletion_log', Array, false)
#5 src/XF/Mvc/Entity/Entity.php(1306): XF\Mvc\Entity\Entity->_saveToSource()
#6 src/XF/Mvc/Entity/Entity.php(1324): XF\Mvc\Entity\Entity->save(true, false)
#7 src/XF/Entity/ProfilePost.php(704): XF\Mvc\Entity\Entity->save()
#8 src/XF/Service/ProfilePost/DeleterService.php(71): XF\Entity\ProfilePost->softDelete('', Object(***\***\XF\Entity\User))
#9 src/XF/Pub/Controller/ProfilePostController.php(181): XF\Service\ProfilePost\DeleterService->delete('soft', '')
#10 src/XF/Mvc/Dispatcher.php(364): XF\Pub\Controller\ProfilePostController->actionDelete(Object(XF\Mvc\ParameterBag))
#11 src/XF/Mvc/Dispatcher.php(266): XF\Mvc\Dispatcher->dispatchClass('XF:ProfilePost', 'Delete', Object(XF\Mvc\RouteMatch), Object(XF\Pub\Controller\ProfilePostController), NULL)
#12 src/XF/Mvc/Dispatcher.php(121): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(XF\Pub\Controller\ProfilePostController), NULL)
#13 src/XF/Mvc/Dispatcher.php(63): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#14 src/XF/App.php(2830): XF\Mvc\Dispatcher->run()
#15 src/XF.php(850): XF\App->run()
#16 index.php(23): XF::runApp('XF\\Pub\\App')
#17 {main}
Request state
array(4) {
  ["url"] => string(29) "/profile-posts/5354653/delete"
  ["referrer"] => string(52) "***"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(7) {
    ["_xfToken"] => string(8) "********"
    ["reason"] => string(0) ""
    ["hard_delete"] => string(1) "0"
    ["_xfRedirect"] => string(52) "***"
    ["_xfResponseType"] => string(4) "json"
    ["_xfWithData"] => string(1) "1"
    ["_xfRequestUri"] => string(26) "***"
  }
}
Similar race conditions have been reported and fixed in the past.
 
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.3.14).

Change log:
Fix deletion race
There may be a delay before changes are rolled out to the XenForo Community.
 
Back
Top Bottom