You are here

function admin_menu_flush_cache in Administration menu 6

Same name and namespace in other branches
  1. 8.3 admin_menu.inc \admin_menu_flush_cache()
  2. 6.3 admin_menu.inc \admin_menu_flush_cache()
  3. 7.3 admin_menu.inc \admin_menu_flush_cache()

Flush all caches or a specific one.

Parameters

$name: (optional) Name of cache to flush.

1 string reference to 'admin_menu_flush_cache'
admin_menu_menu in ./admin_menu.module
Implementation of hook_menu().

File

./admin_menu.inc, line 520

Code

function admin_menu_flush_cache($name = NULL) {

  // URL token protects this against CSRF attacks.
  if (!isset($_GET['token']) || $_GET['token'] !== drupal_get_token($_GET['q'])) {
    return MENU_ACCESS_DENIED;
  }
  switch ($name) {
    case 'admin_menu':
      admin_menu_wipe();
      break;
    case 'cache':

      // Don't clear cache_form - in-progress form submissions may break.
      // Ordered so clearing the page cache will always be the last action.
      $core = array(
        'cache',
        'cache_block',
        'cache_filter',
        'cache_page',
      );
      $cache_tables = array_merge(module_invoke_all('flush_caches'), $core);
      foreach ($cache_tables as $table) {
        cache_clear_all('*', $table, TRUE);
      }
      break;
    case 'menu':
      menu_rebuild();
      break;
    case 'requisites':

      // Change query-strings on css/js files to enforce reload for all users.
      _drupal_flush_css_js();
      drupal_clear_css_cache();
      drupal_clear_js_cache();
      break;
    case 'theme':
      module_invoke('system', 'theme_data');
      drupal_rebuild_theme_registry();
      break;
    default:

      // Flush all caches; no need to re-implement this.
      module_load_include('inc', 'system', 'system.admin');
      $form = $form_state = array();
      system_clear_cache_submit($form, $form_state);
      break;
  }
  drupal_goto();
}