You are here

function variable_init in Drupal 6

Same name and namespace in other branches
  1. 4 includes/bootstrap.inc \variable_init()
  2. 5 includes/bootstrap.inc \variable_init()

Load 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.

1 call to variable_init()
_drupal_bootstrap in includes/bootstrap.inc

File

includes/bootstrap.inc, line 558
Functions that need to be loaded on every Drupal request.

Code

function variable_init($conf = array()) {

  // NOTE: caching the variables improves performance by 20% when serving cached pages.
  if ($cached = cache_get('variables', 'cache')) {
    $variables = $cached->data;
  }
  else {
    $result = db_query('SELECT * FROM {variable}');
    while ($variable = db_fetch_object($result)) {
      $variables[$variable->name] = unserialize($variable->value);
    }
    cache_set('variables', $variables);
  }
  foreach ($conf as $name => $value) {
    $variables[$name] = $value;
  }
  return $variables;
}