Commit 859642ea authored by webchick's avatar webchick

Issue #1888734 by catch, katbailey: Get rid of all 'bootstrap' hooks.

parent af411e00
......@@ -1006,22 +1006,6 @@ function drupal_page_is_cacheable($allow_caching = NULL) {
&& !drupal_is_cli();
}
/**
* Invokes a bootstrap hook in all bootstrap modules that implement it.
*
* @param $hook
* The name of the bootstrap hook to invoke.
*
* @see bootstrap_hooks()
*/
function bootstrap_invoke_all($hook) {
$module_handler = Drupal::moduleHandler();
foreach ($module_handler->getBootstrapModules() as $module) {
$module_handler->load($module);
module_invoke($module, $hook);
}
}
/**
* Includes a file with the provided type and name.
*
......@@ -1324,13 +1308,6 @@ function drupal_serve_page_from_cache(stdClass $cache, Response $response, Reque
$response->setContent($cache->data['body']);
}
/**
* Defines the critical hooks that force modules to always be loaded.
*/
function bootstrap_hooks() {
return array('watchdog');
}
/**
* Translates a string to the current language or to a given language.
*
......@@ -2120,9 +2097,6 @@ function _drupal_bootstrap_variables() {
// Load variables from the database, but do not overwrite variables set in settings.php.
$conf = variable_initialize(isset($conf) ? $conf : array());
// Load bootstrap modules.
require_once __DIR__ . '/module.inc';
Drupal::moduleHandler()->loadBootstrapModules();
}
/**
......
......@@ -3084,6 +3084,7 @@ function drupal_valid_token($token, $value = '', $skip_anonymous = FALSE) {
*/
function _drupal_bootstrap_code() {
require_once __DIR__ . '/../../' . settings()->get('path_inc', 'core/includes/path.inc');
require_once __DIR__ . '/module.inc';
require_once __DIR__ . '/theme.inc';
require_once __DIR__ . '/pager.inc';
require_once __DIR__ . '/../../' . settings()->get('menu_inc', 'core/includes/menu.inc');
......@@ -4732,11 +4733,6 @@ function drupal_flush_all_caches() {
// actually loaded.
$module_handler->loadAll();
// Update the list of bootstrap modules.
// Allows developers to get new bootstrap hooks implementations registered
// without having to write a hook_update_N() function.
_system_update_bootstrap_status();
// Rebuild the schema and cache a fully-built schema based on new module data.
// This is necessary for any invocation of index.php, because setting cache
// table entries requires schema information and that occurs during bootstrap
......
......@@ -143,6 +143,10 @@ function update_prepare_d8_bootstrap() {
// Bootstrap the database.
drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);
// module.inc is not yet loaded but there are calls to module_config_sort()
// below.
require_once __DIR__ . '/module.inc';
// If the site has not updated to Drupal 8 yet, check to make sure that it is
// running an up-to-date version of Drupal 7 before proceeding. Note this has
// to happen AFTER the database bootstraps because of
......
......@@ -45,24 +45,6 @@ public function __construct(array $module_list = array(), KeyValueStoreInterface
$this->bootstrapCache = $bootstrap_cache;
}
/**
* Implements \Drupal\Core\Extension\ModuleHandlerInterface::getBootstrapModules().
*/
public function getBootstrapModules() {
if (isset($this->bootstrapModules)) {
return $this->bootstrapModules;
}
if ($cached = $this->bootstrapCache->get('bootstrap_modules')) {
$bootstrap_list = $cached->data;
}
else {
$bootstrap_list = $this->state->get('system.module.bootstrap') ?: array();
$this->bootstrapCache->set('bootstrap_modules', $bootstrap_list);
}
$this->bootstrapModules = array_keys($bootstrap_list);
return $this->bootstrapModules;
}
/**
* Overrides \Drupal\Core\Extension\ModuleHandler::getHookInfo().
*/
......
......@@ -28,13 +28,6 @@ class ModuleHandler implements ModuleHandlerInterface {
*/
protected $loadedFiles;
/**
* List of enabled bootstrap modules.
*
* @var array
*/
protected $bootstrapModules;
/**
* List of enabled modules.
*
......@@ -124,17 +117,6 @@ public function reload() {
$this->loadAll();
}
/**
* Implements \Drupal\Core\Extension\ModuleHandlerInterface::loadBootstrapModules().
*/
public function loadBootstrapModules() {
if (!$this->loaded) {
foreach ($this->getBootstrapModules() as $module) {
$this->load($module);
}
}
}
/**
* Implements \Drupal\Core\Extension\ModuleHandlerInterface::isLoaded().
*/
......@@ -159,15 +141,6 @@ public function setModuleList(array $module_list = array()) {
$this->resetImplementations();
}
/**
* Implements \Drupal\Core\Extension\ModuleHandlerInterface::getBootstrapModules().
*/
public function getBootstrapModules() {
// The basic module handler does not know anything about how to retrieve a
// list of bootstrap modules.
return array();
}
/**
* Implements \Drupal\Core\Extension\ModuleHandlerInterface::buildModuleDependencies().
*/
......@@ -649,10 +622,6 @@ public function enable($module_list, $enable_dependencies = TRUE) {
$kernel->updateModules($module_filenames, $module_filenames);
}
// Refresh the list of modules that implement bootstrap hooks.
// @see bootstrap_hooks()
_system_update_bootstrap_status();
// Refresh the schema to include it.
drupal_get_schema(NULL, TRUE);
// Update the theme registry to include it.
......@@ -796,7 +765,6 @@ function disable($module_list, $disable_dependents = TRUE) {
// Invoke hook_modules_disabled before disabling modules,
// so we can still call module hooks to get information.
$this->invokeAll('modules_disabled', array($invoke_modules));
_system_update_bootstrap_status();
// Update the kernel to exclude the disabled modules.
$enabled = $this->getModuleList();
......
......@@ -34,11 +34,6 @@ public function load($name);
*/
public function loadAll();
/**
* Loads all enabled bootstrap modules.
*/
public function loadBootstrapModules();
/**
* Returns whether all modules have been loaded.
*
......@@ -71,11 +66,6 @@ public function getModuleList();
*/
public function setModuleList(array $module_list = array());
/**
* Retrieves the list of bootstrap modules.
*/
public function getBootstrapModules();
/**
* Determines which modules require and are required by each module.
*
......
......@@ -2531,7 +2531,6 @@ function _system_rebuild_module_data() {
'version' => NULL,
'php' => DRUPAL_MINIMUM_PHP,
'files' => array(),
'bootstrap' => 0,
);
// Read info files for each module.
......@@ -2617,23 +2616,6 @@ function system_rebuild_module_data() {
return $modules_cache;
}
/**
* Refreshes the list of bootstrap modules.
*
* This is called internally by module_enable/disable() to flag modules that
* implement hooks used during bootstrap, such as hook_watchdog(). These modules
* are loaded earlier to invoke the hooks.
*/
function _system_update_bootstrap_status() {
$bootstrap_modules = array();
foreach (bootstrap_hooks() as $hook) {
foreach (Drupal::moduleHandler()->getImplementations($hook) as $module) {
$bootstrap_modules[$module] = drupal_get_filename('module', $module);
}
}
Drupal::state()->set('system.module.bootstrap', $bootstrap_modules);
}
/**
* Helper function to scan and collect theme .info.yml data and their engines.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment