From eec321a42d890da1ed1005f02a418258ba41cecf Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 19 Jun 2018 16:18:48 -0700 Subject: [PATCH] (dev/core#174) CRM_Utils_Cache_Interface::delete() - Return bool like PSR-16 The function signature for `delete()` did not specify a return value, and actual behaviors varied depending on the driver (`bool` for memcache, `int` for redis, and `void` for others). This standardizes on returning a bool -- which makes the signature align with PSR-16's `delete()`. --- CRM/Utils/Cache/ArrayCache.php | 2 ++ CRM/Utils/Cache/Interface.php | 1 + CRM/Utils/Cache/Memcache.php | 2 +- CRM/Utils/Cache/Redis.php | 5 +++-- CRM/Utils/Cache/SerializeCache.php | 2 ++ CRM/Utils/Cache/SqlGroup.php | 2 ++ 6 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CRM/Utils/Cache/ArrayCache.php b/CRM/Utils/Cache/ArrayCache.php index d196e5ef95..150f9f7cc0 100644 --- a/CRM/Utils/Cache/ArrayCache.php +++ b/CRM/Utils/Cache/ArrayCache.php @@ -81,9 +81,11 @@ class CRM_Utils_Cache_Arraycache implements CRM_Utils_Cache_Interface { /** * @param string $key + * @return bool */ public function delete($key) { unset($this->_cache[$key]); + return TRUE; } public function flush() { diff --git a/CRM/Utils/Cache/Interface.php b/CRM/Utils/Cache/Interface.php index 0316abe7f1..06cf63b5e4 100644 --- a/CRM/Utils/Cache/Interface.php +++ b/CRM/Utils/Cache/Interface.php @@ -81,6 +81,7 @@ interface CRM_Utils_Cache_Interface { * Delete a value from the cache. * * @param string $key + * @return bool */ public function delete($key); diff --git a/CRM/Utils/Cache/Memcache.php b/CRM/Utils/Cache/Memcache.php index 9444ca1335..3fcc631575 100644 --- a/CRM/Utils/Cache/Memcache.php +++ b/CRM/Utils/Cache/Memcache.php @@ -143,7 +143,7 @@ class CRM_Utils_Cache_Memcache implements CRM_Utils_Cache_Interface { /** * @param $key * - * @return mixed + * @return bool */ public function delete($key) { return $this->_cache->delete($this->_prefix . $key); diff --git a/CRM/Utils/Cache/Redis.php b/CRM/Utils/Cache/Redis.php index 6b50cc86d9..f18d3b8d8b 100644 --- a/CRM/Utils/Cache/Redis.php +++ b/CRM/Utils/Cache/Redis.php @@ -152,10 +152,11 @@ class CRM_Utils_Cache_Redis implements CRM_Utils_Cache_Interface { /** * @param $key * - * @return mixed + * @return bool */ public function delete($key) { - return $this->_cache->delete($this->_prefix . $key); + $this->_cache->delete($this->_prefix . $key); + return TRUE; } /** diff --git a/CRM/Utils/Cache/SerializeCache.php b/CRM/Utils/Cache/SerializeCache.php index 906d9b7246..f0e7d5ca49 100644 --- a/CRM/Utils/Cache/SerializeCache.php +++ b/CRM/Utils/Cache/SerializeCache.php @@ -109,12 +109,14 @@ class CRM_Utils_Cache_SerializeCache implements CRM_Utils_Cache_Interface { /** * @param string $key + * @return bool */ public function delete($key) { if (file_exists($this->fileName($key))) { unlink($this->fileName($key)); } unset($this->_cache[$key]); + return TRUE; } /** diff --git a/CRM/Utils/Cache/SqlGroup.php b/CRM/Utils/Cache/SqlGroup.php index b4d943e451..6bfd8d039a 100644 --- a/CRM/Utils/Cache/SqlGroup.php +++ b/CRM/Utils/Cache/SqlGroup.php @@ -131,12 +131,14 @@ class CRM_Utils_Cache_SqlGroup implements CRM_Utils_Cache_Interface { /** * @param string $key + * @return bool */ public function delete($key) { CRM_Core_BAO_Cache::deleteGroup($this->group, $key, FALSE); CRM_Core_BAO_Cache::$_cache = NULL; // FIXME: remove multitier cache CRM_Utils_Cache::singleton()->flush(); // FIXME: remove multitier cache unset($this->frontCache[$key]); + return TRUE; } public function flush() { -- 2.25.1