summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
Diffstat (limited to 'includes')
-rw-r--r--includes/bootstrap.inc52
-rw-r--r--includes/menu.inc7
-rw-r--r--includes/module.inc4
3 files changed, 50 insertions, 13 deletions
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index c5a8ba404..993b52602 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -519,7 +519,6 @@ function page_get_cache() {
*/
function bootstrap_invoke_all($hook) {
foreach (module_list(TRUE, TRUE) as $module) {
- drupal_load('module', $module);
module_invoke($module, $hook);
}
}
@@ -1285,7 +1284,11 @@ function registry_cache_hook_implementations($hook, $write_to_persistent_cache =
}
if ($write_to_persistent_cache === TRUE) {
- cache_set('hooks', $implementations, 'cache_registry');
+ // Only write this to cache if the implementations data we are going to cache
+ // is different to what we loaded earlier in the request.
+ if ($implementations != registry_get_hook_implementations_cache()) {
+ cache_set('hooks', $implementations, 'cache_registry');
+ }
}
}
@@ -1307,12 +1310,53 @@ function registry_cache_path_files() {
$files[] = $row->filename;
}
if ($files) {
- $menu = menu_get_item();
- cache_set('registry:' . $menu['path'], implode(';', $files), 'cache_registry');
+ sort($files);
+ // Only write this to cache if the file list we are going to cache
+ // is different to what we loaded earlier in the request.
+ if ($files != registry_load_path_files(TRUE)) {
+ $menu = menu_get_item();
+ cache_set('registry:' . $menu['path'], implode(';', $files), 'cache_registry');
+ }
+ }
+ }
+}
+
+/**
+ * registry_load_path_files
+ */
+function registry_load_path_files($return = FALSE) {
+ static $file_cache_data = array();
+ if ($return) {
+ sort($file_cache_data);
+ return $file_cache_data;
+ }
+ $menu = menu_get_item();
+ $cache = cache_get('registry:' . $menu['path'], 'cache_registry');
+ if (!empty($cache->data)) {
+ foreach(explode(';', $cache->data) as $file) {
+ require_once($file);
+ $file_cache_data[] = $file;
}
}
}
/**
+ * registry_get_hook_implementations_cache
+ */
+function registry_get_hook_implementations_cache() {
+ static $implementations;
+ if ($implementations === NULL) {
+ if ($cache = cache_get('hooks', 'cache_registry')) {
+ $implementations = $cache->data;
+ }
+ else {
+ $implementations = array();
+ }
+ }
+ return $implementations;
+}
+
+/**
* @} End of "ingroup registry".
*/
+
diff --git a/includes/menu.inc b/includes/menu.inc
index 1a52d3da4..34a8e74d4 100644
--- a/includes/menu.inc
+++ b/includes/menu.inc
@@ -339,12 +339,7 @@ function menu_execute_active_handler($path = NULL) {
menu_rebuild();
}
if ($router_item = menu_get_item($path)) {
- $cache = cache_get('registry:' . $router_item['path'], 'cache_registry');
- if (!empty($cache->data)) {
- foreach(explode(';', $cache->data) as $file) {
- require_once($file);
- }
- }
+ registry_load_path_files();
if ($router_item['access']) {
if (drupal_function_exists($router_item['page_callback'])) {
return call_user_func_array($router_item['page_callback'], $router_item['page_arguments']);
diff --git a/includes/module.inc b/includes/module.inc
index b7e8bb3e0..568a6da18 100644
--- a/includes/module.inc
+++ b/includes/module.inc
@@ -408,9 +408,7 @@ function module_implements($hook, $sort = FALSE, $refresh = FALSE) {
$implementations = array();
}
else if (!defined('MAINTENANCE_MODE') && empty($implementations)) {
- if ($cache = cache_get('hooks', 'cache_registry')) {
- $implementations = $cache->data;
- }
+ $implementations = registry_get_hook_implementations_cache();
}
if (!isset($implementations[$hook])) {