Problem/Motivation

By default the admin menu is cached by:

  • The current user id (uid).
  • The PHP session id.
  • The current language code.

Some implementations will add extra items to the menu (or alter it) based on the context of the page (e.g. Extra menu items when in an Organic Group).

As the admin menu is by default generated and cached once, the context specific items will be missing/out of place unless the cache is cleared.

Proposed resolution

Get the cache id from a helper function that calls a hook to allow other modules to alter the cache id (cid) by adding extra context parameters to it.

Remaining tasks

  • Create a function to generate the cache id.
  • Replace the code where the cache id is created by the new function.
  • Add a drupal_alter() to the helper function so other modules can add extra context to the cache id.
  • Document the alter hook in the api documentation.

API changes

Extra hook to alter the cache id.

Files: 

Comments

zero2one created an issue. See original summary.

zero2one’s picture

I created a path containing:

  • Function to get the cache id to use "admin_menu_cache_id()". This function will trigger the alter hook.
  • Replaced hard coded cid creation by the "admin_menu_cache_id()" function.
  • Documentation about "hook_admin_menu_cache_id_alter(&$cid)" in the api file.