Skip to content

Instantly share code, notes, and snippets.

@davereid
Last active January 4, 2016 03:09
Show Gist options
  • Save davereid/8560097 to your computer and use it in GitHub Desktop.
Save davereid/8560097 to your computer and use it in GitHub Desktop.
name = Debug
description = Helps debug a corrupted module_implements cache
core = 7.x
<?php
/**
* Implements hook_boot().
*/
function debug_boot() {
// Ensure the module implements cache is cleared on every request so we can be guaranteed that it uses fresh data.
module_implements('', FALSE, TRUE);
}
/**
* Implements hook_module_implements_alter().
*/
function debug_module_implements_alter() {
// Update.php runs hooks in an early bootstrap, but we don't care about that instance.
if (drupal_get_bootstrap_phase() != DRUPAL_BOOTSTRAP_FULL && !defined('MAINTENANCE_MODE')) {
echo "<pre>";
echo "Something called module_implements() before a full bootstrap and all modules are loaded!\n\n";
$backtrace = debug_backtrace();
array_shift($backtrace);
print_r($backtrace);
echo "</pre>";
die;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment