diff --git a/admin_menu.module b/admin_menu.module index 21bff9f..dc82450 100644 --- a/admin_menu.module +++ b/admin_menu.module @@ -5,6 +5,8 @@ * Render an administrative menu as a dropdown menu at the top of the window. */ +define('ADMIN_MENU_CACHE_CID_PREFIX', 'admin_menu:'); + /** * Implements hook_help(). */ @@ -154,7 +156,7 @@ function admin_menu_page_build(&$page) { if (strpos($_GET['q'], 'js/') === 0) { return; } - global $user, $language; + global $user; $path = drupal_get_path('module', 'admin_menu'); $page['page_bottom']['admin_menu'] = array( @@ -184,7 +186,7 @@ function admin_menu_page_build(&$page) { // If the client supports JavaScript and we have a cached menu for the current // user, only output the hash for the client-side HTTP cache callback URL. - $cid = 'admin_menu:' . $user->uid . ':' . session_id() . ':' . $language->language; + $cid = admin_menu_cache_get_cid(); if (!$complete && !empty($_COOKIE['has_js']) && ($hash = admin_menu_cache_get($cid))) { $settings['hash'] = $hash; // The base path to use for cache requests depends on whether clean URLs @@ -276,6 +278,18 @@ function admin_menu_js() { } /** + * Helper function to construct the cache id (cid). + */ +function admin_menu_cache_get_cid() { + global $user, $language; + + $cid = ADMIN_MENU_CACHE_CID_PREFIX . $user->uid . ':' . session_id() . ':' . $language->language; + drupal_alter('admin_menu_cache_cid', $cid); + + return $cid; +} + +/** * Retrieve a client-side cache hash from cache. * * The hash cache is consulted more than once per request; we therefore cache @@ -451,10 +465,8 @@ function admin_menu_session_count($timestamp = 0, $anonymous = TRUE) { * page. */ function admin_menu_output($complete = FALSE) { - global $user, $language; - $cache_server_enabled = !$complete && variable_get('admin_menu_cache_server', TRUE); - $cid = 'admin_menu:' . $user->uid . ':' . session_id() . ':' . $language->language; + $cid = admin_menu_cache_get_cid(); // Try to load and output administration menu from server-side cache. // @todo Duplicates the page cache? Page cache ID contains the hash that is @@ -787,7 +799,7 @@ function admin_menu_flush_caches($uid = NULL) { } $was_flushed[$uid] = TRUE; - $cid = 'admin_menu:'; + $cid = ADMIN_MENU_CACHE_CID_PREFIX; if (isset($uid)) { $cid .= $uid . ':'; }