You are here

function features_semaphore in Features 7

Same name and namespace in other branches
  1. 6 features.export.inc \features_semaphore()
  2. 7.2 features.export.inc \features_semaphore()

Processing semaphore operations.

2 calls to features_semaphore()
features_get_component_states in ./features.export.inc
Retrieve an array of features/components and their current states.
_features_restore in ./features.module
Restore the specified modules to the default state.
1 string reference to 'features_semaphore'
features_uninstall in ./features.install
Implements hook_uninstall().

File

./features.export.inc, line 578

Code

function features_semaphore($op, $component) {

  // Note: we don't use variable_get() here as the inited variable
  // static cache may be stale. Retrieving directly from the DB narrows
  // the possibility of collision.
  $semaphore = db_query("SELECT value FROM {variable} WHERE name = :name", array(
    ':name' => 'features_semaphore',
  ))
    ->fetchField();
  $semaphore = !empty($semaphore) ? unserialize($semaphore) : array();
  switch ($op) {
    case 'get':
      return isset($semaphore[$component]) ? $semaphore[$component] : FALSE;
    case 'set':
      $semaphore[$component] = REQUEST_TIME;
      variable_set('features_semaphore', $semaphore);
      break;
    case 'del':
      if (isset($semaphore[$component])) {
        unset($semaphore[$component]);
        variable_set('features_semaphore', $semaphore);
      }
      break;
  }
}