From 2f3e740eb905addfcd00da4583f0513a8198880d Mon Sep 17 00:00:00 2001 From: Jamie McClelland Date: Mon, 27 Feb 2023 11:36:04 -0500 Subject: [PATCH] ensure delays from transactions don't cause cache race condition https://lab.civicrm.org/dev/core/-/issues/3988 --- CRM/Core/Lock.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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); + } } } -- 2.25.1