From 7c8d68afbf676446f6446f9bdf8bcbfafa92bdcf Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Thu, 10 Sep 2015 16:15:13 +0200 Subject: Fix it_cache to pass tests on PHP7 (different code paths because of memcached instead of apcu/memcache) --- it_cache.class | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/it_cache.class b/it_cache.class index 27be919..c5b8b2c 100644 --- a/it_cache.class +++ b/it_cache.class @@ -48,10 +48,17 @@ static function get($key, $p = array()) { $p = it_cache::_defaults($p); - if ($result = $GLOBALS['it_cache_local'][$key]) - ; # Use local copy + if (isset($GLOBALS['it_cache_local'][$key])) + { + # Use local copy + $result = $GLOBALS['it_cache_local'][$key]; + $success = true; + } else if ($p['distributed'] && ($memcache = it_cache::_get_memcache($p))) - $result = $success = @$memcache->get($key); + { + $result = @$memcache->get($key); + $success = !$memcache->getResultCode(); + } else $result = ($func = self::$_fetch_func) ? $func($key, $success) : null; @@ -103,7 +110,10 @@ static function _get_memcache($p) static function _memcache_local_fetch($key, &$success) { if ($memcache = it_cache::_get_memcache(it_cache::_defaults(array()))) - $result = $success = @$memcache->get(self::_memcache_local_key($key)); + { + $result = @$memcache->get(self::_memcache_local_key($key)); + $success = !$memcache->getResultCode(); + } return $result; } -- cgit v1.2.3