Created
July 23, 2014 23:30
-
-
Save jameswilson/36f609fd7bb93004a8e2 to your computer and use it in GitHub Desktop.
Check for Dead Drupal 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 | |
// Place script in root directory of Drupal installation. | |
// From https://www.drupal.org/node/1080330#comment-6520842 | |
define('DRUPAL_ROOT', getcwd()); | |
require_once DRUPAL_ROOT . '/includes/bootstrap.inc'; | |
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); | |
function nobueno() { | |
$startingtime = microtime(true); | |
$o = '<p>Checking for dead modules ...</p>'; | |
$result = db_select('system') | |
->fields('system', array('filename')) | |
->condition('status', '1', '=') | |
->range(0, 150) | |
->execute(); | |
$n = 1; | |
$m = 0; | |
foreach ($result as $node) { | |
$path = DRUPAL_ROOT.'/'.$node->filename; | |
If (!file_exists($path)) { | |
$o .= "#$n $path<br>"; | |
$m++; | |
} | |
$n++; | |
} | |
$timedif = round(microtime(true) - $startingtime,3); | |
$o .= "Total of $n active modules registered in database. $m dead entries found.<br>"; | |
$o .= 'Query Time: '.$timedif.' seconds'; | |
return $o; | |
} | |
echo nobueno(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment