Fixed xf_deletion_log: Race condition when deleting media items via inline moderation

nocte

Well-known member
Affected version
XFMG 2.3.5
We get this quite frequently:

Code:
XF\Db\DuplicateKeyException: MySQL query error [1062]: Duplicate entry 'xfmg_media-3860250' for key 'xf_deletion_log.PRIMARY' src/XF/Db/AbstractStatement.php:230
Generated by: *** 17.8.2025 at 21:47
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/addons/XFMG/Entity/MediaItem.php(1310): XF\Mvc\Entity\Entity->save()
#8 src/addons/XFMG/Service/Media/Deleter.php(68): XFMG\Entity\MediaItem->softDelete('', Object(***\***\XF\Entity\User))
#9 src/addons/XFMG/InlineMod/Media/Delete.php(42): XFMG\Service\Media\Deleter->delete('soft', '')
#10 src/XF/InlineMod/AbstractAction.php(175): XFMG\InlineMod\Media\Delete->applyToEntity(Object(***\***\XFMG\Entity\MediaItem), Array)
#11 src/XF/InlineMod/AbstractAction.php(161): XF\InlineMod\AbstractAction->applyInternal(Object(XF\Mvc\Entity\ArrayCollection), Array)
#12 src/XF/Pub/Controller/InlineModController.php(133): XF\InlineMod\AbstractAction->apply(Object(XF\Mvc\Entity\ArrayCollection), Array)
#13 src/addons/Siropu/AdsManager/XF/Pub/Controller/InlineMod.php(54): XF\Pub\Controller\InlineModController->actionPerform()
#14 src/XF/Mvc/Dispatcher.php(362): Siropu\AdsManager\XF\Pub\Controller\InlineMod->actionPerform(Object(XF\Mvc\ParameterBag))
#15 src/XF/Mvc/Dispatcher.php(264): XF\Mvc\Dispatcher->dispatchClass('XF\\Pub\\Controll...', 'Perform', Object(XF\Mvc\RouteMatch), Object(Siropu\AdsManager\XF\Pub\Controller\InlineMod), Object(XF\Mvc\Reply\Reroute))
#16 src/XF/Mvc/Dispatcher.php(121): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(Siropu\AdsManager\XF\Pub\Controller\InlineMod), Object(XF\Mvc\Reply\Reroute))
#17 src/XF/Mvc/Dispatcher.php(63): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#18 src/XF/App.php(2824): XF\Mvc\Dispatcher->run()
#19 src/XF.php(806): XF\App->run()
#20 index.php(23): XF::runApp('XF\\Pub\\App')
#21 {main}
Request state
array(4) {
  ["url"] => string(12) "/inline-mod/"
  ["referrer"] => string(58) "***"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(11) {
    ["_xfToken"] => string(8) "********"
    ["reason"] => string(0) ""
    ["hard_delete"] => string(1) "0"
    ["ids"] => array(4) {
      [0] => string(7) "3860250"
      [1] => string(7) "3870045"
      [2] => string(7) "3870051"
      [3] => string(7) "3870100"
    }
    ["type"] => string(10) "xfmg_media"
    ["action"] => string(6) "delete"
    ["confirmed"] => string(1) "1"
    ["_xfRedirect"] => string(58) "***"
    ["_xfResponseType"] => string(4) "json"
    ["_xfWithData"] => string(1) "1"
    ["_xfRequestUri"] => string(32) "***"
  }
}

Similar to this one in XF core:

 
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 XFMG release (2.3.8).

Change log:
Prevent a race condition related to soft-deleting media items
There may be a delay before changes are rolled out to the XenForo Community.
 
Back
Top Bottom