Skip to content

Instantly share code, notes, and snippets.

@jameswilson
Created July 23, 2014 23:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jameswilson/36f609fd7bb93004a8e2 to your computer and use it in GitHub Desktop.
Save jameswilson/36f609fd7bb93004a8e2 to your computer and use it in GitHub Desktop.
Check for Dead Drupal Modules
<?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