public function _indexForSearch() { if (SV_DeadlockAvoidance_DataWriter::registerPostTransactionClosure(function () { parent::_indexForSearch(); })) { return; } parent::_indexForSearch(); }
protected function _postSaveAfterTransaction() { if (SV_DeadlockAvoidance_DataWriter::registerPostTransactionClosure(function () { parent::_postSaveAfterTransaction(); })) { return; } parent::_postSaveAfterTransaction(); }
public function sendAlertsOnReportRejection(array $report, $comment = '') { if (SV_DeadlockAvoidance_DataWriter::registerPostTransactionClosure(function () use($report, $comment) { parent::sendAlertsOnReportRejection($report, $comment); })) { return; } parent::sendAlertsOnReportRejection($report, $comment); }
public function deleteAlerts($contentType, $contentId, $userId = null, $action = null) { if (SV_DeadlockAvoidance_DataWriter::registerPostTransactionClosure(function () use($contentType, $contentId, $userId, $action) { parent::deleteAlerts($contentType, $contentId, $userId, $action); })) { return; } parent::deleteAlerts($contentType, $contentId, $userId, $action); }
public function rebuildUnreadConversationCountForUser($userId) { if (SV_DeadlockAvoidance_DataWriter::registerPostTransactionClosure(function () use($userId) { XenForo_Db::beginTransaction(); parent::rebuildUnreadConversationCountForUser($userId); XenForo_Db::commit(); })) { return; } parent::rebuildUnreadConversationCountForUser($userId); }
public function mergePosts(array $posts, array $threads, $targetPostId, $newMessage, $options = array()) { // hoist bits out of the mergePosts Transaction SV_DeadlockAvoidance_DataWriter::enterTransaction(); $ret = false; try { $ret = parent::mergePosts($posts, $threads, $targetPostId, $newMessage, $options); } finally { SV_DeadlockAvoidance_DataWriter::exitTransaction($ret); } return $ret; }
public static function exitTransaction($executePostTransaction) { self::$transactionCount -= 1; if (self::$transactionCount <= 0) { self::$transactionCount = 0; $postSaveAfterTransactionList = array_reverse(self::$postSaveAfterTransactionList); self::$postSaveAfterTransactionList = array(); if ($executePostTransaction) { foreach ($postSaveAfterTransactionList as $postSaveAfterTransaction) { $postSaveAfterTransaction(); } } } }
public function likeContent($contentType, $contentId, $contentUserId, $likeUserId = null, $likeDate = null) { // hoist bits out of the Like Transaction SV_DeadlockAvoidance_DataWriter::enterTransaction(); $ret = false; try { $ret = parent::likeContent($contentType, $contentId, $contentUserId, $likeUserId, $likeDate); } catch (Zend_Db_Statement_Mysqli_Exception $e) { SV_DeadlockAvoidance_DataWriter::exitTransaction(false); @XenForo_Db::rollbackAll(); // something went wrong, retry if (stripos($e->getMessage(), "Deadlock found when trying to get lock; try restarting transaction") !== false) { SV_DeadlockAvoidance_DataWriter::enterTransaction(); $ret = parent::likeContent($contentType, $contentId, $contentUserId, $likeUserId, $likeDate); } else { throw $e; } } finally { SV_DeadlockAvoidance_DataWriter::exitTransaction($ret); } return $ret; }