Skip to content

Instantly share code, notes, and snippets.

@slivorezka
Created April 20, 2016 14:35
Show Gist options
  • Save slivorezka/d78f03ef2f5984431c3df813234e1487 to your computer and use it in GitHub Desktop.
Save slivorezka/d78f03ef2f5984431c3df813234e1487 to your computer and use it in GitHub Desktop.
<?php
/**
* @file
* Install
*/
/**
* Implements hook_uninstall().
*/
function MODULE_uninstall() {
// Remove all variables.
$variables = db_select('variable', 'v')
->fields('v', array('name'))
->condition('v.name', db_like('MODULE') . '%', 'LIKE')
->execute()
->fetchAllAssoc('name');
if (!empty($variables)) {
global $conf;
$variables = array_keys($variables);
// Delete.
foreach ($variables as $variable_name) {
db_delete('variable')->condition('name', $variable_name)->execute();
unset($conf[$variable_name]);
}
// Cache clear.
cache_clear_all('variables', 'cache_bootstrap');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment