From 5052356574813655713ae123204b57a3b45000f4 Mon Sep 17 00:00:00 2001 From: Sam Hemelryk Date: Fri, 11 Jan 2013 17:08:57 +1300 Subject: [PATCH] MDL-37470 cache: definitions can now be purged through config screen --- cache/admin.php | 10 +++++++++- cache/locallib.php | 6 +++++- lang/en/cache.php | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/cache/admin.php b/cache/admin.php index cf3de513c2beb..56592ee74a603 100644 --- a/cache/admin.php +++ b/cache/admin.php @@ -129,7 +129,7 @@ } break; case 'editdefinitionmapping' : // Edit definition mappings. - $definition = required_param('definition', PARAM_TEXT); + $definition = required_param('definition', PARAM_ALPHANUMEXT); $title = get_string('editdefinitionmappings', 'cache', $definition); $mform = new cache_definition_mappings_form($PAGE->url, array('definition' => $definition)); if ($mform->is_cancelled()) { @@ -167,6 +167,14 @@ } break; + case 'purgedefinition': // Purge a specific definition. + $definition = required_param('definition', PARAM_ALPHANUMEXT); + list($component, $area) = explode('/', $definition, 2); + cache_helper::purge_by_definition($component, $area); + redirect($PAGE->url, get_string('purgedefinitionsuccess', 'cache'), 5); + break; + + case 'purgestore': case 'purge': // Purge a store cache. $store = required_param('store', PARAM_TEXT); cache_helper::purge_store($store); diff --git a/cache/locallib.php b/cache/locallib.php index 76888b7e78271..70c061e15425d 100644 --- a/cache/locallib.php +++ b/cache/locallib.php @@ -695,6 +695,10 @@ public static function get_definition_actions(context $context) { array( 'text' => get_string('editmappings', 'cache'), 'url' => new moodle_url('/cache/admin.php', array('action' => 'editdefinitionmapping', 'sesskey' => sesskey())) + ), + array( + 'text' => get_string('purge', 'cache'), + 'url' => new moodle_url('/cache/admin.php', array('action' => 'purgedefinition', 'sesskey' => sesskey())) ) ); } @@ -724,7 +728,7 @@ public static function get_store_instance_actions($name, array $storedetails) { } $actions[] = array( 'text' => get_string('purge', 'cache'), - 'url' => new moodle_url($baseurl, array('action' => 'purge')) + 'url' => new moodle_url($baseurl, array('action' => 'purgestore')) ); } return $actions; diff --git a/lang/en/cache.php b/lang/en/cache.php index 208e9a455d923..64d772be57c1c 100644 --- a/lang/en/cache.php +++ b/lang/en/cache.php @@ -92,6 +92,7 @@ $string['plugin'] = 'Plugin'; $string['pluginsummaries'] = 'Installed cache stores'; $string['purge'] = 'Purge'; +$string['purgedefinitionsuccess'] = 'Successfully purged the requested definition.'; $string['purgestoresuccess'] = 'Successfully purged the requested store.'; $string['requestcount'] = 'Test with {$a} requests'; $string['rescandefinitions'] = 'Rescan definitions';