Created
May 11, 2014 11:16
-
-
Save derhasi/05fe6cba3b849359c3aa to your computer and use it in GitHub Desktop.
Deregister features info for disabled obsolete modules
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 | |
/** | |
* 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; | |
} | |
// 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