1 bootstrap.inc variable_initialize($conf = array())

Loads the persistent variable table.

The variable table is composed of values that have been saved in the table with variable_set() as well as those explicitly specified in the configuration file.


since 1.0


core/includes/bootstrap.inc, line 1123
Functions that need to be loaded on every Backdrop request.


function variable_initialize($conf = array()) {
  // watchdog_deprecated_function() is not called here even though this function
  // is deprecated because this function is *always* called during bootstrap.

  // NOTE: caching the variables improves performance by 20% when serving
  // cached pages.
  if ($cached = cache('bootstrap')->get('variables')) {
    $variables = $cached->data;
  else {
    // Cache miss. Avoid a stampede.
    $name = 'variable_init';
    if (!lock_acquire($name, 1)) {
      // Another request is building the variable cache.
      // Wait, then re-run this function.
      return variable_initialize($conf);
    else {
      // Proceed with variable rebuild.
      $variables = array_map('unserialize', db_query('SELECT name, value FROM {variable}')->fetchAllKeyed());
      cache('bootstrap')->set('variables', $variables);

  foreach ($conf as $name => $value) {
    $variables[$name] = $value;

  return $variables;