How do I empty Drupal Cache (without Devel)

前端 未结 12 2572
小鲜肉
小鲜肉 2021-02-18 18:07

How do I empty the Drupal caches:

  • without the Devel module
  • without running some PHP Statement in a new node etc.
  • without going i
12条回答
  •  庸人自扰
    2021-02-18 18:44

    The following module creates a menu item that is accessible only to users with the permission "flush cache", which this module makes available on the regular user permissions page.

    /**
     * Implementation of hook_menu()
     */
    function flush_cache_menu() {
      $items = array();
    
      $items['flush-cache'] = array(
      'type' => MENU_NORMAL_ITEM,
      'title' => t('Flush the cache'),
      'description' => 'Flush all website caches to make sure it updates to relect '.
        'your recent changes.',
      'page callback' => 'flush_cache_custom_callback',
      'access callback' => user_access('flush cache'),
      );
    
      return $items;
    }
    
    /**
     * Implementation of hook_perm()
     */
    function flush_cache_perm() {
      return array('flush cache');
    }
    
    /**
     * Function that flushes the cache
     */
    function flush_cache_custom_callback() {
      drupal_flush_all_caches();
      return 'Caches were flushed.';
    }
    

提交回复
热议问题