From 376b7fb857fe2c97fffda5e95fbcb1eb231f2dc1 Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Fri, 3 May 2019 13:02:08 +0100 Subject: [PATCH] MDL-65492 cache admin: make it easier to purge a cache repeatedly This can be a big time-saver, e.g. during development. --- cache/admin.php | 21 +++++++++++++++++---- lang/en/cache.php | 9 +++++++-- lang/en/deprecated.txt | 2 ++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/cache/admin.php b/cache/admin.php index fb1997a2e27c5..f8931b60601d0 100644 --- a/cache/admin.php +++ b/cache/admin.php @@ -208,8 +208,8 @@ break; case 'purgedefinition': // Purge a specific definition. - $definition = required_param('definition', PARAM_SAFEPATH); - list($component, $area) = explode('/', $definition, 2); + $id = required_param('definition', PARAM_SAFEPATH); + list($component, $area) = explode('/', $id, 2); $factory = cache_factory::instance(); $definition = $factory->create_definition($component, $area); if ($definition->has_required_identifiers()) { @@ -219,14 +219,27 @@ // Alrighty we can purge just the data belonging to this definition. cache_helper::purge_by_definition($component, $area); } - redirect($PAGE->url, get_string('purgedefinitionsuccess', 'cache'), 5); + + $message = get_string('purgexdefinitionsuccess', 'cache', [ + 'name' => $definition->get_name(), + 'component' => $component, + 'area' => $area, + ]); + $purgeagainlink = html_writer::link(new moodle_url('/cache/admin.php', [ + 'action' => 'purgedefinition', 'sesskey' => sesskey(), 'definition' => $id]), + get_string('purgeagain', 'cache')); + redirect($PAGE->url, $message . ' ' . $purgeagainlink, 5); break; case 'purgestore': case 'purge': // Purge a store cache. $store = required_param('store', PARAM_TEXT); cache_helper::purge_store($store); - redirect($PAGE->url, get_string('purgestoresuccess', 'cache'), 5); + $message = get_string('purgexstoresuccess', 'cache', ['store' => $store]); + $purgeagainlink = html_writer::link(new moodle_url('/cache/admin.php', [ + 'action' => 'purgestore', 'sesskey' => sesskey(), 'store' => $store]), + get_string('purgeagain', 'cache')); + redirect($PAGE->url, $message . ' ' . $purgeagainlink, 5); break; case 'newlockinstance': diff --git a/lang/en/cache.php b/lang/en/cache.php index 73acbeb08031e..ab5658426db7d 100644 --- a/lang/en/cache.php +++ b/lang/en/cache.php @@ -141,8 +141,9 @@ $string['pluginsummaries'] = 'Installed cache stores'; $string['privacy:metadata:cachestore'] = 'The Cache subsystem stores data temporarily on behalf of other parts of Moodle. This data is not easily identifiable, and is very short lived. It serves as a cache of data stored elsewhere in Moodle, and should therefore already be handled by those Moodle components.'; $string['purge'] = 'Purge'; -$string['purgedefinitionsuccess'] = 'Successfully purged the requested definition.'; -$string['purgestoresuccess'] = 'Successfully purged the requested store.'; +$string['purgeagain'] = 'Purge again'; +$string['purgexdefinitionsuccess'] = 'Successfully purged the "{$a->name}" cache ({$a->component}/{$a->area}).'; +$string['purgexstoresuccess'] = 'Successfully purged the "{$a->store}" store.'; $string['requestcount'] = 'Test with {$a} requests'; $string['rescandefinitions'] = 'Rescan definitions'; $string['result'] = 'Result'; @@ -190,3 +191,7 @@ $string['untestable'] = 'Untestable'; $string['userinputsharingkey'] = 'Custom key for sharing'; $string['userinputsharingkey_help'] = 'Enter your own private key here. When you set up other stores on other sites you wish to share data with make sure you set the exact same key there.'; + +// Deprecated since Moodle 3.8. +$string['purgedefinitionsuccess'] = 'Successfully purged the requested definition.'; +$string['purgestoresuccess'] = 'Successfully purged the requested store.'; diff --git a/lang/en/deprecated.txt b/lang/en/deprecated.txt index 62f8f15734b2a..14eafe9dc3b0a 100644 --- a/lang/en/deprecated.txt +++ b/lang/en/deprecated.txt @@ -158,3 +158,5 @@ backpackbadges,core_badges nobackpackbadges,core_badges nobackpackcollections,core_badges error:nogroups,core_badges +purgedefinitionsuccess,core_cache +purgestoresuccess,core_cache