summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2007-11-26 16:25:14 +0000
committerDries Buytaert <dries@buytaert.net>2007-11-26 16:25:14 +0000
commit22444f2fedf0fbe34423128ede822adc0f82e411 (patch)
tree54b19c132bf4dfb96cacc9e3309f915272bfa189
parent58852d4b7b72113793455b92bf113359e849e2fb (diff)
downloadbrdo-22444f2fedf0fbe34423128ede822adc0f82e411.tar.gz
brdo-22444f2fedf0fbe34423128ede822adc0f82e411.tar.bz2
- Patch #195173 by Eaton et al: allow administrators to clear all caches.
-rw-r--r--includes/common.inc20
-rw-r--r--modules/system/system.admin.inc20
2 files changed, 40 insertions, 0 deletions
diff --git a/includes/common.inc b/includes/common.inc
index 0b91ab5cc..b1c542207 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -3539,3 +3539,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);
+ }
+}
diff --git a/modules/system/system.admin.inc b/modules/system/system.admin.inc
index 07168c502..230183aae 100644
--- a/modules/system/system.admin.inc
+++ b/modules/system/system.admin.inc
@@ -1249,6 +1249,18 @@ function system_performance_settings() {
'#description' => t("This option can interfere with module development. It is recommended to only turn this on when your site is complete."),
);
+ $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. <em>Warning: high-traffic sites will experience performance slowdowns while cached data is rebuilt.</em>'),
+ );
+
+ $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';
@@ -1256,6 +1268,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