Last active
August 29, 2015 14:05
-
-
Save derhasi/e73496c035376d877feb to your computer and use it in GitHub Desktop.
Snippet for making features components of disabled modules available again.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @file | |
* Make features components of disabled modules available again. | |
*/ | |
/** | |
* Implements hook_system_info_alter(). | |
*/ | |
function mycustom_system_info_alter(&$info, $file, $type) { | |
static $files_status = array(); | |
// We want to remove features info from disabled obsolete modules, so we get a | |
// clean component list with all available components. | |
// First check if there is any features info first and quit otherwise. | |
if (!isset($info['features'])) { | |
return; | |
} | |
// Get file status, so we can check if it is enabled currently. | |
if (empty($files_status)) { | |
$files_status = db_query("SELECT filename, name, type, status, schema_version, weight FROM {system} WHERE type = :type", array(':type' => 'module')) | |
->fetchAllAssoc('filename'); | |
} | |
// Quit if we have no file status yet. | |
if (!isset($files_status[$file->filename])) { | |
return; | |
} | |
// Also do nothin if the module is enabled. | |
elseif (!empty($files_status[$file->filename]->status)) { | |
return; | |
} | |
// Optionaly we could kick only modules with a given name or folder: | |
// We only want to "kick" obsolete modules, so ignore anyone else. | |
//if (strpos($file->filename, 'obsolete') === FALSE ) { | |
// return; | |
//} | |
// otherwise remove the features info. | |
unset($info['features']); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment