Commit 22444f2f authored by Dries's avatar Dries

- Patch #195173 by Eaton et al: allow administrators to clear all caches.

parent 58852d4b
......@@ -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);
}
}
......@@ -1249,12 +1249,32 @@ 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';
return system_settings_form($form);
}
/**
* 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.
*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment