You are here

function _ec_variable_set in Elysia Cron 6.2

Same name and namespace in other branches
  1. 5.2 elysia_cron.module \_ec_variable_set()
  2. 5 elysia_cron.module \_ec_variable_set()
  3. 6 elysia_cron.module \_ec_variable_set()
  4. 7.2 elysia_cron.module \_ec_variable_set()
  5. 7 elysia_cron.module \_ec_variable_set()

A substitute for variable_set to avoid cache management Use ONLY for variables setted during cron execution: elysia_cron_semaphore, elysia_cron_last_run, elysia_cron_last_context, cron_semaphore, cron_last WARN_UPGRADE

3 calls to _ec_variable_set()
elysia_cron_internal_execute_channel_completed in ./elysia_cron.module
Successful termination (after all shutdown hooks invoked by cron functions).
elysia_cron_run in ./elysia_cron.module
Public function to invoke a complete cron_run
elysia_cron_set_last_channel in ./elysia_cron.module

File

./elysia_cron.module, line 264

Code

function _ec_variable_set($name, $value) {
  global $_ec_variables, $_ec_variables_allowed;
  if (!in_array($name, $_ec_variables_allowed)) {
    elysia_cron_error('Wrong variable passed to _ec_variable_set: !var', array(
      '!var' => $name,
    ), true);
    return variable_set($name, $value);
  }
  if (!is_array($_ec_variables)) {
    _ec_variable_init();
  }
  if (EC_DRUPAL_VERSION >= 7) {
    db_merge('variable')
      ->key(array(
      'name' => $name,
    ))
      ->fields(array(
      'value' => serialize($value),
    ))
      ->execute();
  }
  else {
    if (!variable_get('elysia_cron_alternate_var_handler', false)) {
      db_lock_table('variable');
      db_query("DELETE FROM {variable} WHERE name = '%s'", $name);
      db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", $name, serialize($value));
      db_unlock_tables();
    }
    else {
      db_query("REPLACE INTO {variable} (name, value) VALUES ('%s', '%s')", $name, serialize($value));
    }
  }
  $_ec_variables[$name] = $value;
}