From e8a072673782187f584b7ea82f6ef8f2c6f38e97 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 14 Oct 2015 21:56:01 -0400 Subject: [PATCH] Fix error when Memcached::getAllKeys() fails. Refs #7546 --- lib/Cake/Cache/Engine/MemcachedEngine.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Cache/Engine/MemcachedEngine.php b/lib/Cake/Cache/Engine/MemcachedEngine.php index a2611396a..331b8a352 100644 --- a/lib/Cake/Cache/Engine/MemcachedEngine.php +++ b/lib/Cake/Cache/Engine/MemcachedEngine.php @@ -273,7 +273,8 @@ class MemcachedEngine extends CacheEngine { * * @param bool $check If true no deletes will occur and instead CakePHP will rely * on key TTL values. - * @return bool True if the cache was successfully cleared, false otherwise + * @return bool True if the cache was successfully cleared, false otherwise. Will + * also return false if you are using a binary protocol. */ public function clear($check) { if ($check) { @@ -281,6 +282,9 @@ class MemcachedEngine extends CacheEngine { } $keys = $this->_Memcached->getAllKeys(); + if ($keys === false) { + return false; + } foreach ($keys as $key) { if (strpos($key, $this->settings['prefix']) === 0) {