Commit 5083e135 authored by Dries's avatar Dries

- Patch #333143 by justinrandell: cleaning up the Drupal bootstrap code,...

- Patch #333143 by justinrandell: cleaning up the Drupal bootstrap code, removing bootstrap flag in system table.
parent 8e985b3f
......@@ -673,18 +673,6 @@ function page_get_cache() {
return $cache;
}
/**
* Call all init or exit hooks without including all modules.
*
* @param $hook
* The name of the bootstrap hook we wish to invoke.
*/
function bootstrap_invoke_all($hook) {
foreach (module_implements($hook) as $module) {
module_invoke($module, $hook);
}
}
/**
* Includes a file with the provided type and name. This prevents
* including a theme, engine, module, etc., more than once.
......@@ -789,13 +777,6 @@ function drupal_page_cache_header($cache) {
print $cache->data;
}
/**
* Define the critical hooks that force modules to always be loaded.
*/
function bootstrap_hooks() {
return array('boot', 'exit');
}
/**
* Unserializes and appends elements from a serialized string.
*
......@@ -1157,14 +1138,14 @@ function _drupal_bootstrap($phase) {
if (!$cache || $cache_mode != CACHE_AGGRESSIVE) {
// Load module handling.
require_once DRUPAL_ROOT . '/includes/module.inc';
bootstrap_invoke_all('boot');
module_invoke_all('boot');
}
// If there is a cached page, display it.
if ($cache) {
drupal_page_cache_header($cache);
// If the skipping of the bootstrap hooks is not enforced, call hook_exit.
if ($cache_mode != CACHE_AGGRESSIVE) {
bootstrap_invoke_all('exit');
module_invoke_all('exit');
}
// We are done.
exit;
......@@ -1368,7 +1349,7 @@ function drupal_get_schema($table = NULL, $rebuild = FALSE) {
// "prime" module_list() here to to values we want, specifically
// "yes rebuild the list and don't limit to bootstrap".
// TODO: Remove this call after http://drupal.org/node/222109 is fixed.
module_list(TRUE, FALSE);
module_list(TRUE);
module_load_all_includes('install');
}
......
......@@ -571,7 +571,7 @@ function drupal_install_system() {
$system_versions = drupal_get_schema_versions('system');
$system_version = $system_versions ? max($system_versions) : SCHEMA_INSTALLED;
db_query("INSERT INTO {system} (filename, name, type, owner, status, bootstrap, schema_version) VALUES('%s', '%s', '%s', '%s', %d, %d, %d)", $system_path . '/system.module', 'system', 'module', '', 1, 0, $system_version);
db_query("INSERT INTO {system} (filename, name, type, owner, status, schema_version) VALUES('%s', '%s', '%s', '%s', %d, %d)", $system_path . '/system.module', 'system', 'module', '', 1, $system_version);
// Now that we've installed things properly, bootstrap the full Drupal environment
drupal_install_init_database();
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
......
......@@ -21,7 +21,7 @@
* Load all the modules that have been enabled in the system table.
*/
function module_load_all() {
foreach (module_list(TRUE, FALSE) as $module) {
foreach (module_list(TRUE) as $module) {
drupal_load('module', $module);
}
}
......@@ -33,9 +33,6 @@ function module_load_all() {
* @param $refresh
* Whether to force the module list to be regenerated (such as after the
* administrator has changed the system settings).
* @param $bootstrap
* Whether to return the reduced set of modules loaded in "bootstrap mode"
* for cached pages. See bootstrap.inc.
* @param $sort
* By default, modules are ordered by weight and filename. Set this option to
* TRUE to return a module list ordered only by module name.
......@@ -46,7 +43,7 @@ function module_load_all() {
* An associative array whose keys and values are the names of all loaded
* modules.
*/
function module_list($refresh = FALSE, $bootstrap = TRUE, $sort = FALSE, $fixed_list = NULL) {
function module_list($refresh = FALSE, $sort = FALSE, $fixed_list = NULL) {
static $list = array(), $sorted_list;
if (empty($list) || $refresh || $fixed_list) {
......@@ -59,12 +56,7 @@ function module_list($refresh = FALSE, $bootstrap = TRUE, $sort = FALSE, $fixed_
}
}
else {
if ($bootstrap) {
$result = db_query("SELECT name, filename FROM {system} WHERE type = 'module' AND status = 1 AND bootstrap = 1 ORDER BY weight ASC, filename ASC");
}
else {
$result = db_query("SELECT name, filename FROM {system} WHERE type = 'module' AND status = 1 ORDER BY weight ASC, filename ASC");
}
$result = db_query("SELECT name, filename FROM {system} WHERE type = 'module' AND status = 1 ORDER BY weight ASC, filename ASC");
while ($module = db_fetch_object($result)) {
if (file_exists($module->filename)) {
drupal_get_filename('module', $module->name, $module->filename);
......@@ -125,24 +117,14 @@ function module_rebuild_cache() {
// modify the data in the .info files if necessary.
drupal_alter('system_info', $files[$filename]->info, $files[$filename]);
// Log the critical hooks implemented by this module.
$bootstrap = 0;
foreach (bootstrap_hooks() as $hook) {
// Only look for hooks in installed modules.
if (!empty($file->status) && in_array($file->name, module_implements($hook))) {
$bootstrap = 1;
break;
}
}
// Update the contents of the system table:
if (isset($file->status) || (isset($file->old_filename) && $file->old_filename != $file->filename)) {
db_query("UPDATE {system} SET info = '%s', name = '%s', filename = '%s', bootstrap = %d WHERE filename = '%s'", serialize($files[$filename]->info), $file->name, $file->filename, $bootstrap, $file->old_filename);
db_query("UPDATE {system} SET info = '%s', name = '%s', filename = '%s' WHERE filename = '%s'", serialize($files[$filename]->info), $file->name, $file->filename, $file->old_filename);
}
else {
// This is a new module.
$files[$filename]->status = 0;
db_query("INSERT INTO {system} (name, info, type, filename, status, bootstrap) VALUES ('%s', '%s', '%s', '%s', %d, %d)", $file->name, serialize($files[$filename]->info), 'module', $file->filename, 0, $bootstrap);
db_query("INSERT INTO {system} (name, info, type, filename, status) VALUES ('%s', '%s', '%s', '%s', %d)", $file->name, serialize($files[$filename]->info), 'module', $file->filename, 0);
}
}
$files = _module_build_dependencies($files);
......@@ -295,7 +277,7 @@ function module_enable($module_list) {
if (!empty($invoke_modules)) {
// Refresh the module list to include the new enabled module.
module_list(TRUE, FALSE);
module_list(TRUE);
// Force to regenerate the stored list of hook implementations.
registry_rebuild();
}
......@@ -345,7 +327,7 @@ function module_disable($module_list) {
// so we can still call module hooks to get information.
module_invoke_all('modules_disabled', $invoke_modules);
// Refresh the module list to exclude the disabled modules.
module_list(TRUE, FALSE);
module_list(TRUE);
// Force to regenerate the stored list of hook implementations.
registry_rebuild();
}
......
......@@ -39,7 +39,7 @@ function _drupal_maintenance_theme() {
// Load module basics (needed for hook invokes).
$module_list['system']['filename'] = 'modules/system/system.module';
$module_list['filter']['filename'] = 'modules/filter/filter.module';
module_list(TRUE, FALSE, FALSE, $module_list);
module_list(TRUE, FALSE, $module_list);
drupal_load('module', 'system');
drupal_load('module', 'filter');
......
......@@ -52,7 +52,7 @@ function install_main() {
include_once DRUPAL_ROOT . '/includes/module.inc';
$module_list['system']['filename'] = 'modules/system/system.module';
$module_list['filter']['filename'] = 'modules/filter/filter.module';
module_list(TRUE, FALSE, FALSE, $module_list);
module_list(TRUE, FALSE, $module_list);
drupal_load('module', 'system');
drupal_load('module', 'filter');
......
......@@ -940,7 +940,7 @@ function system_modules_submit($form, &$form_state) {
drupal_install_modules($new_modules);
}
$current_module_list = module_list(TRUE, FALSE);
$current_module_list = module_list(TRUE);
if ($old_module_list != $current_module_list) {
drupal_set_message(t('The configuration options have been saved.'));
}
......
......@@ -1208,12 +1208,6 @@ function system_schema() {
'not null' => TRUE,
'default' => 0,
),
'bootstrap' => array(
'description' => "Boolean indicating whether this module is loaded during Drupal's early bootstrapping phase (e.g. even before the page cache is consulted).",
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'schema_version' => array(
'description' => "The module's database schema version number. -1 if the module is not installed (its tables do not exist); 0 or the largest N of the module's hook_update_N() function that has either been run or existed when the module was first installed.",
'type' => 'int',
......@@ -1236,7 +1230,6 @@ function system_schema() {
'primary key' => array('filename'),
'indexes' => array(
'modules' => array(array('type', 12), 'status', 'weight', 'filename'),
'bootstrap' => array(array('type', 12), 'status', 'bootstrap', 'weight', 'filename'),
),
);
......@@ -3130,6 +3123,15 @@ function system_update_7013() {
return $ret;
}
/**
* Drop the bootstrap column from the {system} table.
*/
function system_update_7014() {
$ret = array();
db_drop_field($ret, 'system', 'bootstrap');
return $ret;
}
/**
* @} End of "defgroup updates-6.x-to-7.x"
* The next series of updates should start at 8000.
......
......@@ -1088,7 +1088,7 @@ function system_theme_data() {
$theme->owner = '';
}
db_query("INSERT INTO {system} (name, owner, info, type, filename, status, bootstrap) VALUES ('%s', '%s', '%s', '%s', '%s', %d, %d)", $theme->name, $theme->owner, serialize($theme->info), 'theme', $theme->filename, isset($theme->status) ? $theme->status : 0, 0);
db_query("INSERT INTO {system} (name, owner, info, type, filename, status) VALUES ('%s', '%s', '%s', '%s', '%s', %d)", $theme->name, $theme->owner, serialize($theme->info), 'theme', $theme->filename, isset($theme->status) ? $theme->status : 0);
}
return $themes;
......
......@@ -133,7 +133,7 @@ class EnableDisableCoreTestCase extends DrupalWebTestCase {
* @param boolean $enabled Module state.
*/
function assertModules(Array $modules, $enabled) {
module_list(TRUE, FALSE);
module_list(TRUE);
foreach ($modules as $module) {
if ($enabled) {
$message = 'Module "@module" is enabled.';
......
......@@ -663,7 +663,7 @@ function update_check_requirements() {
include_once DRUPAL_ROOT . '/includes/module.inc';
$module_list['system']['filename'] = 'modules/system/system.module';
$module_list['filter']['filename'] = 'modules/filter/filter.module';
module_list(TRUE, FALSE, FALSE, $module_list);
module_list(TRUE, FALSE, $module_list);
drupal_load('module', 'system');
drupal_load('module', 'filter');
......
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