From f9bbcc5302c438cc1ec01b9f42bf227d30434c4a Mon Sep 17 00:00:00 2001 From: Sam Hemelryk Date: Wed, 27 Feb 2013 18:22:28 +1300 Subject: [PATCH] MDL-38165 cache: fixed up application event purging --- cache/classes/loaders.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/cache/classes/loaders.php b/cache/classes/loaders.php index 62d6f67b859..6402e2c823b 100644 --- a/cache/classes/loaders.php +++ b/cache/classes/loaders.php @@ -1094,10 +1094,11 @@ class cache_application extends cache implements cache_loader_with_locking { $cache = cache::make('core', 'eventinvalidation'); $events = $cache->get_many($definition->get_invalidation_events()); $todelete = array(); + $purgeall = false; // Iterate the returned data for the events. foreach ($events as $event => $keys) { if ($keys === false) { - // There are no keys. + // No data to be invalidated yet. continue; } // Look at each key and check the timestamp. @@ -1105,11 +1106,18 @@ class cache_application extends cache implements cache_loader_with_locking { // If the timestamp of the event is more than or equal to the last invalidation (happened between the last // invalidation and now)then we need to invaliate the key. if ($timestamp >= $lastinvalidation) { - $todelete[] = $key; + if ($key === 'purged') { + $purgeall = true; + break; + } else { + $todelete[] = $key; + } } } } - if (!empty($todelete)) { + if ($purgeall) { + $this->purge(); + } else if (!empty($todelete)) { $todelete = array_unique($todelete); $this->delete_many($todelete); }