function update_variable_get

Gets the value of a variable from the database during 7.x-8.x upgrades.

Use this during the 7.x-8.x upgrade path instead of variable_get().

Parameters

string $name: The name of the variable.

mixed $default: The default value of the variable.

Return value

mixed The value of the variable in the database unserialized, or NULL if not set.

See also

update_variable_set()

update_variable_del()

Related topics

20 calls to update_variable_get()
book_update_8000 in drupal/core/modules/book/book.install
Move the Book module settings from variables to config.
color_update_8001 in drupal/core/modules/color/color.install
Converts variables to config.
DateUpgradePathTest::testDateUpgrade in drupal/core/modules/system/lib/Drupal/system/Tests/Upgrade/DateUpgradePathTest.php
Tests that date formats have been upgraded.
LanguageUpgradePathTest::testLanguageUpgrade in drupal/core/modules/system/lib/Drupal/system/Tests/Upgrade/LanguageUpgradePathTest.php
Tests a successful upgrade.
locale_update_8001 in drupal/core/modules/locale/locale.install
Language type 'language' renamed to 'language_interface'.

... See full list

File

drupal/core/includes/update.inc, line 1298
Drupal database update API.

Code

function update_variable_get($name, $default = NULL) {
  $result = db_query('SELECT value FROM {variable} WHERE name = :name', array(
    ':name' => $name,
  ))
    ->fetchField();
  if ($result !== FALSE) {
    return unserialize($result);
  }
  return $default;
}