Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.720 diff -u -p -r1.720 common.inc --- includes/common.inc 23 Nov 2007 13:34:55 -0000 1.720 +++ includes/common.inc 25 Nov 2007 18:59:29 -0000 @@ -3536,3 +3536,24 @@ function drupal_implode_tags($tags) { return implode(', ', $encoded_tags); } +/** + * Flush the contents of all cached data on the site. + * + * Empties cache tables, rebuilds the menu cache and theme registries, and + * exposes a hook for other modules to clear their own cache data as well. + */ +function drupal_flush_caches() { + // Compile a list of all cache tables in both core and contributed modules. + $cache_tables = array('cache', 'cache_block', 'cache_filter', 'cache_form', 'cache_page'); + $cache_tables = array_merge($cache_tables, module_invoke_all('flush_caches')); + + // Clear each cache table, along with other system-level caches. + foreach ($cache_tables as $table) { + cache_clear_all('*', $table, TRUE); + } + + drupal_clear_css_cache(); + drupal_clear_js_cache(); + drupal_rebuild_theme_registry(); + menu_rebuild(); +} Index: modules/system/system.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v retrieving revision 1.25 diff -u -p -r1.25 system.admin.inc --- modules/system/system.admin.inc 23 Nov 2007 15:36:44 -0000 1.25 +++ modules/system/system.admin.inc 25 Nov 2007 18:59:31 -0000 @@ -1263,6 +1263,17 @@ function system_performance_settings() { '#description' => t('Enable this setting to determine the correct IP address of the remote client by examining information stored in the X-Forwarded-For headers. X-Forwarded-For headers are a standard mechanism for identifying client systems connecting through a reverse proxy server, such as Squid or Pound. Reverse proxy servers are often used to enhance the performance of heavily visited sites and may also provide other site caching, security or encryption benefits. If this Drupal installation operates behind a reverse proxy, this setting should be enabled so that correct IP address information is captured in Drupal\'s session management, logging, statistics and access management systems; if you are unsure about this setting, do not have a reverse proxy, or Drupal operates in a shared hosting environment, this setting should be set to disabled.'), ); + $form['clear_cache'] = array( + '#type' => 'fieldset', + '#description' => t('Caching data improves performance, but developers may experience problems troubleshooting new modules or themes if outdated information has been cached. To clear all cached data from your site, click the button below. Warning: high-traffic sites will experience performance slowdowns while cached data is rebuilt.'), + ); + + $form['clear_cache']['cache'] = array( + '#type' => 'submit', + '#value' => t('Clear cached data'), + '#submit' => array('system_clear_cache_submit'), + ); + $form['#submit'][] = 'drupal_clear_css_cache'; $form['#submit'][] = 'drupal_clear_js_cache'; @@ -1270,6 +1281,14 @@ function system_performance_settings() { } /** + * Clear system caches. + */ +function system_clear_cache_submit(&$form_state, $form) { + drupal_flush_caches(); + drupal_set_message('Caches cleared.'); +} + +/** * Form builder; Configure the site file handling. * * @ingroup forms