function admin_menu_flush_caches in Administration menu 7.3
Same name and namespace in other branches
- 6.3 admin_menu.module \admin_menu_flush_caches()
Implements hook_flush_caches().
Flushes client-side caches.
Parameters
int $uid: (optional) A user ID to limit the cache flush to.
9 calls to admin_menu_flush_caches()
- admin_menu_comment_delete in ./
admin_menu.module - Implements hook_comment_delete().
- admin_menu_comment_insert in ./
admin_menu.module - Implements hook_comment_insert().
- admin_menu_comment_update in ./
admin_menu.module - Implements hook_comment_update().
- admin_menu_form_alter_flush_cache_submit in ./
admin_menu.module - Form submission handler to flush Administration menu caches.
- admin_menu_menu_alter in ./
admin_menu.module - Implements hook_menu_alter().
File
- ./
admin_menu.module, line 899 - Render an administrative menu as a dropdown menu at the top of the window.
Code
function admin_menu_flush_caches($uid = NULL) {
// A call to menu_rebuild() will trigger potentially thousands of calls into
// menu_link_save(), for which admin_menu has to implement the corresponding
// CRUD hooks, in order to take up any menu link changes, since any menu link
// change could affect the admin menu (which essentially is an aggregate) and
// since there is no other way to get notified about stale caches. The cache
// only needs to be flushed once though, so we prevent a ton of needless
// subsequent calls with this static.
// @see http://drupal.org/node/918538
$was_flushed =& drupal_static(__FUNCTION__, array());
// $uid can be NULL. PHP automatically converts that into '' (empty string),
// which is different to uid 0 (zero).
if (isset($was_flushed[$uid])) {
return;
}
$was_flushed[$uid] = TRUE;
$cid = 'admin_menu:';
if (isset($uid)) {
$cid .= $uid . ':';
}
// Flush cached output of admin_menu.
cache_clear_all($cid, 'cache_menu', TRUE);
// Flush client-side cache hashes.
drupal_static_reset('admin_menu_cache_get');
// If cache_admin_menu is not empty, flush it.
if (!cache_is_empty('cache_admin_menu')) {
cache_clear_all(isset($uid) ? $cid : '*', 'cache_admin_menu', TRUE);
}
}