You are here

public static function UltimateCronLock::isLockedMultiple in Ultimate Cron 7.2

Check multiple locks.

Parameters

array $names: The names of the locks to check.

Return value

array Array of lock ids.

File

./ultimate_cron.lock.inc, line 183
A database-mediated implementation of a locking mechanism.

Class

UltimateCronLock
Class for handling lock functions.

Code

public static function isLockedMultiple($names) {
  $target = _ultimate_cron_get_transactional_safe_connection();
  $now = microtime(TRUE);
  $result = db_select('ultimate_cron_lock', 'l', array(
    'target' => $target,
  ))
    ->fields('l', array(
    'lid',
    'name',
    'expire',
  ))
    ->condition('name', $names, 'IN')
    ->condition('current', 0)
    ->execute()
    ->fetchAllAssoc('name');
  foreach ($names as $name) {
    if (!isset($result[$name])) {
      $result[$name] = FALSE;
    }
    else {
      $result[$name] = $result[$name]->expire > $now ? $result[$name]->lid : FALSE;
    }
  }
  return $result;
}