From b5e7d576c210272df41af475b4ee7b36967b4e43 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 4 Feb 2019 16:27:09 -0500 Subject: [PATCH] CRM_Core_BAO_Cache - When delegating to an adapter, don't expect it to return a reference This is following up on the code-review comments from https://github.com/civicrm/civicrm-core/pull/13489#discussion_r252070543 --- CRM/Core/BAO/Cache.php | 3 ++- CRM/Core/BAO/Cache/Psr16.php | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CRM/Core/BAO/Cache.php b/CRM/Core/BAO/Cache.php index 2087170a35..4590cb3b29 100644 --- a/CRM/Core/BAO/Cache.php +++ b/CRM/Core/BAO/Cache.php @@ -68,7 +68,8 @@ class CRM_Core_BAO_Cache extends CRM_Core_DAO_Cache { */ public static function &getItem($group, $path, $componentID = NULL) { if (($adapter = CRM_Utils_Constant::value('CIVICRM_BAO_CACHE_ADAPTER')) !== NULL) { - return $adapter::getItem($group, $path, $componentID); + $value = $adapter::getItem($group, $path, $componentID); + return $value; } if (self::$_cache === NULL) { diff --git a/CRM/Core/BAO/Cache/Psr16.php b/CRM/Core/BAO/Cache/Psr16.php index 852a4a3c25..48ae52994d 100644 --- a/CRM/Core/BAO/Cache/Psr16.php +++ b/CRM/Core/BAO/Cache/Psr16.php @@ -86,7 +86,7 @@ class CRM_Core_BAO_Cache_Psr16 { * @return object * The data if present in cache, else null */ - public static function &getItem($group, $path, $componentID = NULL) { + public static function getItem($group, $path, $componentID = NULL) { // TODO: Generate a general deprecation notice. if ($componentID) { Civi::log() @@ -95,8 +95,7 @@ class CRM_Core_BAO_Cache_Psr16 { 'path' => $path, ]); } - $value = self::getGroup($group)->get(CRM_Core_BAO_Cache::cleanKey($path)); - return $value; + return self::getGroup($group)->get(CRM_Core_BAO_Cache::cleanKey($path)); } /** -- 2.25.1