From: Jamie McClelland Date: Mon, 27 Feb 2023 16:36:04 +0000 (-0500) Subject: ensure delays from transactions don't cause cache race condition X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=2f3e740eb905addfcd00da4583f0513a8198880d;p=civicrm-core.git ensure delays from transactions don't cause cache race condition https://lab.civicrm.org/dev/core/-/issues/3988 --- diff --git a/CRM/Core/Lock.php b/CRM/Core/Lock.php index 67adc99c02..76ae9c12ff 100644 --- a/CRM/Core/Lock.php +++ b/CRM/Core/Lock.php @@ -212,7 +212,14 @@ class CRM_Core_Lock implements \Civi\Core\Lock\LockInterface { $query = "SELECT RELEASE_LOCK( %1 )"; $params = [1 => [$this->_id, 'String']]; - return CRM_Core_DAO::singleValueQuery($query, $params); + if (CRM_Core_Transaction::isActive()) { + CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_POST_COMMIT, function () { + return CRM_Core_DAO::singleValueQuery($query, $params); + }); + } + else { + return CRM_Core_DAO::singleValueQuery($query, $params); + } } }