diff --git a/core/includes/common.inc b/core/includes/common.inc index 722c1f6..a88a3be 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -5047,6 +5047,10 @@ function _drupal_bootstrap_full() { drupal_theme_initialize(); module_invoke_all('init'); } + if (variable_get('registry_rebuild') && !defined('MAINTENANCE_MODE')) { + registry_rebuild(); + variable_del('registry_rebuild'); + } } /** diff --git a/core/update.php b/core/update.php index d1a0940..3a3858b 100644 --- a/core/update.php +++ b/core/update.php @@ -348,6 +348,54 @@ function update_check_requirements($skip_warnings = FALSE) { } } +function update_rebuild_registry() { + // Do enough rebuilding so Drupal can boot. Hooks are not invoked here. + require_once DRUPAL_ROOT . '/core/includes/common.inc'; + require_once DRUPAL_ROOT . '/core/includes/registry.inc'; + + $connection_info = Database::getConnectionInfo(); + $driver = $connection_info['default']['driver']; + require_once DRUPAL_ROOT . '/core/includes/database/query.inc'; + require_once DRUPAL_ROOT . '/core/includes/database/select.inc'; + require_once DRUPAL_ROOT . '/core/includes/database/' . $driver . '/query.inc'; + + // Get current list of modules and their files. + $modules = db_query("SELECT * FROM {system} WHERE type = 'module' AND status = 1")->fetchAll(); + // Get the list of files we are going to parse. + $files = array(); + foreach ($modules as &$module) { + $dir = dirname($module->filename); + + // Store the module directory for use in hook_registry_files_alter(). + $module->dir = $dir; + $module->info = drupal_parse_info_file($module->dir . '/' . $module->name . '.info'); + if (isset($module->info['files'])) { + // Add files for enabled modules to the registry. + foreach ($module->info['files'] as $file) { + $files["$dir/$file"] = array('module' => $module->name, 'weight' => $module->weight); + } + } + } + foreach (new RecursiveDirectoryIterator(DRUPAL_ROOT . '/core/includes') as $file) { + $filename = $file->getPathname(); + if (substr($filename, -4) == '.inc') { + $files[$filename] = array('module' => '', 'weight' => 0); + } + } + + $transaction = db_transaction(); + try { + db_truncate('registry')->execute(); + db_truncate('registry_file')->execute(); + _registry_parse_files($files); + } + catch (Exception $e) { + $transaction->rollback(); + throw $e; + } + variable_set('registry_rebuild', TRUE); +} + // Some unavoidable errors happen because the database is not yet up-to-date. // Our custom error handler is not yet installed, so we just suppress them. ini_set('display_errors', FALSE); @@ -392,6 +440,8 @@ if (empty($op) && update_access_allowed()) { // stage, since the real requirements check happens further down. update_check_requirements(TRUE); + update_rebuild_registry(); + // Redirect to the update information page if all requirements were met. install_goto('core/update.php?op=info'); }