From 216b7f757751b5462e31c96be1fdf703f0baf68e Mon Sep 17 00:00:00 2001 From: Skylar Kelty Date: Fri, 29 Apr 2016 12:14:34 +0100 Subject: [PATCH] MDL-53967 caching: Ensure getAllKeys returns a valid array --- cache/stores/memcached/lib.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cache/stores/memcached/lib.php b/cache/stores/memcached/lib.php index 9ecb706b023..84ec315fc6c 100644 --- a/cache/stores/memcached/lib.php +++ b/cache/stores/memcached/lib.php @@ -508,9 +508,14 @@ class cachestore_memcached extends cache_store implements cache_is_configurable * @return array */ protected static function get_prefixed_keys(Memcached $connection, $prefix) { + $connkeys = $connection->getAllKeys(); + if (empty($connkeys)) { + return array(); + } + $keys = array(); $start = strlen($prefix); - foreach ($connection->getAllKeys() as $key) { + foreach ($connkeys as $key) { if (strpos($key, $prefix) === 0) { $keys[] = substr($key, $start); }