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 26 Nov 2007 02:56:24 -0000 @@ -3536,3 +3536,23 @@ function drupal_implode_tags($tags) { return implode(', ', $encoded_tags); } +/** + * Flush 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_all_caches() { + drupal_clear_css_cache(); + drupal_clear_js_cache(); + drupal_rebuild_theme_registry(); + menu_rebuild(); + node_types_rebuild(); + // 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); + } +} 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 26 Nov 2007 02:56:24 -0000 @@ -280,8 +280,7 @@ function system_themes_form_submit($form } list_themes(TRUE); - menu_rebuild(); - drupal_rebuild_theme_registry(); + drupal_flush_all_caches(); drupal_set_message(t('The configuration options have been saved.')); $form_state['redirect'] = 'admin/build/themes'; @@ -566,10 +565,7 @@ function _system_is_incompatible(&$incom * The form array. */ function system_modules($form_state = array()) { - drupal_rebuild_theme_registry(); - node_types_rebuild(); - menu_rebuild(); - cache_clear_all('schema', 'cache'); + drupal_flush_all_caches(); // Get current list of modules. $files = module_rebuild_cache(); @@ -1263,6 +1259,18 @@ 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', + '#title' => t('Clear cached data'), + '#description' => t('Caching data improves performance, but may cause problems while troubleshooting new modules, themes, or translations, if outdated information has been cached. To refresh all cached data on 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 +1278,14 @@ function system_performance_settings() { } /** + * Clear system caches. + */ +function system_clear_cache_submit(&$form_state, $form) { + drupal_flush_all_caches(); + drupal_set_message('Caches cleared.'); +} + +/** * Form builder; Configure the site file handling. * * @ingroup forms