}
// grab a lock so other processes dont compete and do the same query
- $lockName = "civicrm.group.{$groupID}";
- $lock = new CRM_Core_Lock($lockName);
+ $lock = Civi\Core\Container::singleton()->get('lockManager')->acquire("data.core.group.{$groupID}");
if (!$lock->isAcquired()) {
// this can cause inconsistent results since we dont know if the other process
// will fill up the cache before our calling routine needs it.
// get a lock so that multiple ajax requests on the same page
// dont trample on each other
// CRM-11234
- $lockName = "civicrm.cache.{$group}_{$path}._{$componentID}";
- $lock = new CRM_Core_Lock($lockName);
+ $lock = Civi\Core\Container::singleton()->get('lockManager')->acquire("cache.{$group}_{$path}._{$componentID}");
if (!$lock->isAcquired()) {
CRM_Core_Error::fatal();
}
if (self::$jobLog && CRM_Core_DAO::singleValueQuery("SELECT IS_USED_LOCK( '" . self::$jobLog . "')")) {
return $this->hackyHandleBrokenCode(self::$jobLog);
}
- if (stristr($name, 'civimail.job.')) {
+ if (stristr($name, 'data.mailing.job.')) {
self::$jobLog = $this->_name;
}
$this->_timeout = $timeout !== NULL ? $timeout : self::TIMEOUT;
shuffle($lockArray);
// check if we are using global locks
- $serverWideLock = CRM_Core_BAO_Setting::getItem(
- CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
- 'civimail_server_wide_lock'
- );
foreach ($lockArray as $lockID) {
- $cronLock = new CRM_Core_Lock("civimail.cronjob.{$lockID}", NULL, $serverWideLock);
+ $cronLock = Civi\Core\Container::singleton()->get('lockManager')->acquire("worker.mailing.send.{$lockID}");
if ($cronLock->isAcquired()) {
$gotCronLock = TRUE;
break;
while ($job->fetch()) {
// still use job level lock for each child job
- $lockName = "civimail.job.{$job->id}";
-
- $lock = new CRM_Core_Lock($lockName);
+ $lock = Civi\Core\Container::singleton()->get('lockManager')->acquire("data.mailing.job.{$job->id}");
if (!$lock->isAcquired()) {
continue;
}
// X Number of child jobs
while ($job->fetch()) {
// still use job level lock for each child job
- $lockName = "civimail.job.{$job->id}";
-
- $lock = new CRM_Core_Lock($lockName);
+ $lock = Civi\Core\Container::singleton()->get('lockManager')->acquire("data.mailing.job.{$job->id}");
if (!$lock->isAcquired()) {
continue;
}
// in that case (ie. makes it non-configurable via the UI). Another approach would be to set a default of 0
// in the _spec function - but since that is a deprecated value it seems more contentious than this approach
$params['rowCount'] = 0;
- $lock = new CRM_Core_Lock('civimail.job.EmailProcessor');
+ $lock = Civi\Core\Container::singleton()->get('lockManager')->acquire('worker.core.ActionSchedule');
if (!$lock->isAcquired()) {
- return civicrm_api3_create_error('Could not acquire lock, another EmailProcessor process is running');
+ return civicrm_api3_create_error('Could not acquire lock, another ActionSchedule process is running');
}
$result = CRM_Core_BAO_ActionSchedule::processQueue(CRM_Utils_Array::value('now', $params), $params);
* @return array
*/
function civicrm_api3_job_fetch_bounces($params) {
- $lock = new CRM_Core_Lock('civimail.job.EmailProcessor');
+ $lock = Civi\Core\Container::singleton()->get('lockManager')->acquire('worker.mailing.EmailProcessor');
if (!$lock->isAcquired()) {
return civicrm_api3_create_error('Could not acquire lock, another EmailProcessor process is running');
}
* @return array
*/
function civicrm_api3_job_fetch_activities($params) {
- $lock = new CRM_Core_Lock('civimail.job.EmailProcessor');
+ $lock = Civi\Core\Container::singleton()->get('lockManager')->acquire('worker.mailing.EmailProcessor');
if (!$lock->isAcquired()) {
return civicrm_api3_create_error('Could not acquire lock, another EmailProcessor process is running');
}
* true if success, else false
*/
function civicrm_api3_job_process_membership($params) {
- $lock = new CRM_Core_Lock('civimail.job.updateMembership');
+ $lock = Civi\Core\Container::singleton()->get('lockManager')->acquire('worker.member.UpdateMembership');
if (!$lock->isAcquired()) {
return civicrm_api3_create_error('Could not acquire lock, another Membership Processing process is running');
}
* @throws \API_Exception
*/
function civicrm_api3_job_group_rebuild($params) {
- $lock = new CRM_Core_Lock('civimail.job.groupRebuild');
+ $lock = Civi\Core\Container::singleton()->get('lockManager')->acquire('worker.core.GroupRebuild');
if (!$lock->isAcquired()) {
throw new API_Exception('Could not acquire lock, another EmailProcessor process is running');
}
//log the execution of script
CRM_Core_Error::debug_log_message('ContributionProcessor.php');
-require_once 'CRM/Core/Lock.php';
-$lock = new CRM_Core_Lock('CiviContributeProcessor');
+$lock = Civi\Core\Container::singleton()->get('lockManager')->acquire('worker.contribute.CiviContributeProcessor');
if ($lock->isAcquired()) {
// try to unset any time limits
CiviContributeProcessor::process();
}
else {
- throw new Exception('Could not acquire lock, another CiviMailProcessor process is running');
+ throw new Exception('Could not acquire lock, another CiviContributeProcessor process is running');
}
$lock->release();
}
public function run() {
- require_once 'CRM/Core/Lock.php';
- $lock = new CRM_Core_Lock('CiviReportMail');
+ $lock = Civi\Core\Container::singleton()->get('lockManager')->acquire('worker.report.CiviReportMail');
if ($lock->isAcquired()) {
// try to unset any time limits
//if it doesn't die, it's authenticated
//log the execution of script
CRM_Core_Error::debug_log_message('EmailProcessor.php from the cli');
- require_once 'CRM/Core/Lock.php';
- $lock = new CRM_Core_Lock('EmailProcessor');
+ $lock = Civi\Core\Container::singleton()->get('lockManager')->acquire('worker.mailing.EmailProcessor');
if (!$lock->isAcquired()) {
throw new Exception('Could not acquire lock, another EmailProcessor process is running');
//log the execution of script
CRM_Core_Error::debug_log_message('EmailProcessor.php');
- require_once 'CRM/Core/Lock.php';
- $lock = new CRM_Core_Lock('EmailProcessor');
+ $lock = Civi\Core\Container::singleton()->get('lockManager')->acquire('worker.mailing.EmailProcessor');
if (!$lock->isAcquired()) {
throw new Exception('Could not acquire lock, another EmailProcessor process is running');