Return to Snippet

Revision: 9758
at November 20, 2008 14:22 by tgbdad


Updated Code
<?php
/*
 * See http://drupal.org/node/152983 for details!
 */

// only allow site administrators to visit this page:
if (!user_access('administer site configuration')) {
  drupal_not_found();
}
else {
  drupal_clear_css_cache();
  $tables = array(
    'cache',
    'cache_content',
    'cache_filter',
    'cache_menu',
    'cache_page',
    'cache_views',
  );
  foreach ($tables as $table) {
    cache_clear_all('*', $table, TRUE);
  }
  drupal_set_message('Cache cleared.');
  drupal_goto('/');
}
?>

Revision: 9757
at November 20, 2008 14:20 by tgbdad


Initial Code
<?php
/* See http://drupal.org/node/152983
/*
 * 2008 Jun 26
 *
 * The code submitted by dharmanerd in his comment probably
 * works better than the original I had, so I've modified this
 * to match his code.
 *
 * The original code for this was shamelessly yanked from
 * `devel.module`; it was the function `devel_cache_clear()`.
 *
 */

// only allow site administrators to visit this page:
if (!user_access('administer site configuration')) {
  drupal_not_found();
}
else {
  drupal_clear_css_cache();
  $tables = array(
    'cache',
    'cache_content',
    'cache_filter',
    'cache_menu',
    'cache_page',
    'cache_views',
  );
  foreach ($tables as $table) {
    cache_clear_all('*', $table, TRUE);
  }
  drupal_set_message('Cache cleared.');
  drupal_goto('/');
}
?>

Initial URL
http://drupal.org/node/152983

Initial Description
This might work in Drupal 6, but I haven't tried it.

Initial Title
Clear Drupal 5 Cache

Initial Tags
drupal

Initial Language
PHP