You are here

function hierarchical_select_update_7003 in Hierarchical Select 7.3

Update system variable keys. Issue #1368916.

File

./hierarchical_select.install, line 89
Install, update and uninstall functions for the Hierarchical Select module.

Code

function hierarchical_select_update_7003() {
  module_load_include('inc', 'hierarchical_select', 'includes/common');

  // Retrieve our keys.
  $result = db_select('variable', 'v')
    ->fields('v', array(
    'name',
  ))
    ->condition('v.name', 'hs_config%', 'LIKE')
    ->execute()
    ->fetchAll();
  foreach ($result as $id => $var) {
    $key = $var->name;

    // Get our current value for the key.
    $val = variable_get($key, array());

    // Sanitize our key.
    $new_key = hierarchical_select_common_sanitize_var($key);

    // Write the value to the new key.
    variable_set($new_key, $val);

    // Delete the previous variable.
    variable_del($key);
  }
}