function vars_modules_uninstalled in Variable API 7
Same name and namespace in other branches
- 7.2 vars.module \vars_modules_uninstalled()
Implements hook_modules_uninstalled().
File
- ./
vars.module, line 391 - Implement an API to handle persistent variables.
Code
function vars_modules_uninstalled($modules) {
global $conf;
$defaults = db_select('variable_default', 'vd')
->condition('vd.module', $modules, 'IN')
->fields('vd', array(
'name',
'value',
'flags',
))
->execute();
$variables = array();
foreach ($defaults as $default) {
$name = $default->name;
if ($default->flags & self::VARS_DYNAMIC) {
$name_like = db_like($name . '_') . '%';
$vars = db_select('variable', 'v')
->condition(db_or()
->condition('v.name', $name_like, 'LIKE')
->condition('v.name', $name))
->fields('v', array(
'name',
))
->execute();
foreach ($vars as $var) {
unset($conf[$var->name]);
$variables[] = $var->name;
}
}
else {
$variables[] = $name;
unset($conf[$name]);
}
}
if (!empty($variables)) {
db_delete('variable')
->condition('name', $variables, 'IN')
->execute();
db_delete('variable_default')
->condition('module', $modules, 'IN')
->execute();
foreach ($modules as $module) {
cache_clear_all('module:' . $module, 'cache_vars');
}
cache_clear_all('variables', 'cache_bootstrap');
Vars::staticReset('vars_default_values');
}
}