summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-12-28 10:48:51 +0000
committerDries Buytaert <dries@buytaert.net>2009-12-28 10:48:51 +0000
commit98b84b7adbf2dfee104167e4014ecd03fb965fff (patch)
tree26cb9cae9a031dbf63659e55a5d2c6fb54411378
parentd24e2c1384d66ceb6ba5db7dae6b36f5f3ddfd31 (diff)
downloadbrdo-98b84b7adbf2dfee104167e4014ecd03fb965fff.tar.gz
brdo-98b84b7adbf2dfee104167e4014ecd03fb965fff.tar.bz2
- Patch #661420 by justinrandell, David_Rothstein: made installation of modules much more efficient.
-rw-r--r--includes/bootstrap.inc16
-rw-r--r--includes/module.inc8
-rw-r--r--includes/registry.inc9
-rw-r--r--modules/system/system.api.php20
4 files changed, 34 insertions, 19 deletions
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index 29b925350..b9bf2d6d0 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -2098,8 +2098,22 @@ function _registry_check_code($type, $name = NULL) {
* each interface or class in the database.
*/
function registry_rebuild() {
+ system_rebuild_module_data();
+ registry_update();
+}
+
+/**
+ * Update the registry based on the latest files listed in the database.
+ *
+ * This function should be used when system_rebuild_module_data() does not need
+ * to be called, because it is already known that the list of files in the
+ * {system} table matches those in the file system.
+ *
+ * @see registry_rebuild()
+ */
+function registry_update() {
require_once DRUPAL_ROOT . '/includes/registry.inc';
- _registry_rebuild();
+ _registry_update();
}
/**
diff --git a/includes/module.inc b/includes/module.inc
index ba44dc46e..e3f31a009 100644
--- a/includes/module.inc
+++ b/includes/module.inc
@@ -319,8 +319,8 @@ function module_enable($module_list, $disable_modules_installed_hook = FALSE) {
system_list_reset();
module_list(TRUE);
module_implements('', FALSE, TRUE);
- // Force to regenerate the stored list of hook implementations.
- registry_rebuild();
+ // Update the registry to include the new enabled module.
+ registry_update();
// Refresh the schema to include the new enabled module.
drupal_get_schema(NULL, TRUE);
@@ -383,8 +383,8 @@ function module_disable($module_list) {
// Invoke hook_modules_disabled before disabling modules,
// so we can still call module hooks to get information.
module_invoke_all('modules_disabled', $invoke_modules);
- // Force to regenerate the stored list of hook implementations.
- registry_rebuild();
+ // Update the registry to remove the newly-disabled module.
+ registry_update();
}
// If there remains no more node_access module, rebuilding will be
diff --git a/includes/registry.inc b/includes/registry.inc
index be7154851..16b869b76 100644
--- a/includes/registry.inc
+++ b/includes/registry.inc
@@ -17,9 +17,9 @@
*/
/**
- * @see registry_rebuild.
+ * @see registry_update().
*/
-function _registry_rebuild() {
+function _registry_update() {
// The registry serves as a central autoloader for all classes, including
// the database query builders. However, the registry rebuild process
@@ -35,11 +35,12 @@ function _registry_rebuild() {
require_once DRUPAL_ROOT . '/includes/database/' . $driver . '/query.inc';
// Get current list of modules and their files.
- $modules = system_rebuild_module_data();
+ $modules = db_query("SELECT * FROM {system} WHERE type = 'module'")->fetchAll();
// Get the list of files we are going to parse.
$files = array();
foreach ($modules as &$module) {
- $dir = dirname($module->uri);
+ $module->info = unserialize($module->info);
+ $dir = dirname($module->filename);
// Store the module directory for use in hook_registry_files_alter().
$module->dir = $dir;
diff --git a/modules/system/system.api.php b/modules/system/system.api.php
index 57ad53536..70ba43ea1 100644
--- a/modules/system/system.api.php
+++ b/modules/system/system.api.php
@@ -2192,7 +2192,7 @@ function hook_disable() {
* files found in each enabled module's info file and the core includes
* directory. The array is keyed by the file path and contains an array of
* the related module's name and weight as used internally by
- * _registry_rebuild() and related functions.
+ * _registry_update() and related functions.
*
* For example:
* @code
@@ -2202,17 +2202,17 @@ function hook_disable() {
* );
* @endcode
* @param $modules
- * List of all the modules provided as returned by drupal_system_listing().
- * The list also contains the .info file information in the property 'info'.
- * An additional 'dir' property has been added to the module information
- * which provides the path to the directory in which the module resides. The
- * example shows how to take advantage of the property both properties.
- *
- * @see _registry_rebuild()
- * @see drupal_system_listing()
+ * An array containing all module information stored in the {system} table.
+ * Each element of the array also contains the module's .info file
+ * information in the property 'info'. An additional 'dir' property has been
+ * added to the module information which provides the path to the directory
+ * in which the module resides. The example shows how to take advantage of
+ * both properties.
+ *
+ * @see _registry_update()
* @see simpletest_test_get_all()
*/
-function hook_registry_files_alter(&$files, $module_cache) {
+function hook_registry_files_alter(&$files, $modules) {
foreach ($modules as $module) {
// Only add test files for disabled modules, as enabled modules should
// already include any test files they provide.