Fixed Entity::delete() called without a transaction

Xon

Well-known member
Affected version
2.1.2
In actionDeleteConversations it calls delete with $conversation->delete(false, false);

This means the delete action doesn't run inside a transaction! so any errors in postDelete will leave the entity in an inconsistent state.

This affects the following locations;
  • XF\Admin\Controller\User::actionDeleteConversations
  • XF\Job\UserAction::executeAction
  • XF\Job\ThreadAction::executeAction
  • XFMG\Job\AbstractBatchUpdateAction::run
  • XF\Repository\UserUpgrade::downgradeExpiredUpgrades (expireActiveUpgrade does not use a transaction, but is called inside of one elsewhere)
 
  • XF\Job\UserAction::executeAction
  • XF\Job\ThreadAction::executeAction
  • XFMG\Job\AbstractBatchUpdateAction::run
These all seem to be wrapped in transactions as appropriate to me.

AbstractUserCriteriaJob::run calls executeAction inside the $ids loop but seems to (optionally, but by default) begin and commit the transaction.

XFMG\Job\AbstractBatchUpdateAction::run seems to begin and commit a transaction outside of the $ids loop.

So unless I'm missing something, I've made changes to XF\Admin\Controller\User::actionDeleteConversations and XF\Repository\UserUpgrade::downgradeExpiredUpgrades and that's all we need to do.
 
Thank you for reporting this issue. It has now been resolved and we are aiming to include it in a future XF release (2.1.3).

Change log:
Make use of database transactions in a few entity delete cases where they currently might be skipped.
Any changes made as a result of this issue being resolved may not be rolled out here until later.
 
Top Bottom