From e276754f3819447bfa59b2106aed104aba612bdb Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 18 Sep 2019 14:53:27 +0300 Subject: [ci skip] Update Cache library Redis driver to work with phpRedis 5, similarly to PR #5816 (also add changelog entry) --- system/libraries/Cache/drivers/Cache_redis.php | 13 ++++++++++++- user_guide_src/source/changelog.rst | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/system/libraries/Cache/drivers/Cache_redis.php b/system/libraries/Cache/drivers/Cache_redis.php index e10a5b344..bff96fbfb 100644 --- a/system/libraries/Cache/drivers/Cache_redis.php +++ b/system/libraries/Cache/drivers/Cache_redis.php @@ -76,6 +76,13 @@ class CI_Cache_redis extends CI_Driver */ protected $_serialized = array(); + /** + * del()/delete() method name depending on phpRedis version + * + * @var string + */ + protected static $_delete_name; + // ------------------------------------------------------------------------ /** @@ -97,6 +104,10 @@ class CI_Cache_redis extends CI_Driver return; } + isset(static::$_delete_name) OR static::$_delete_name = version_compare(phpversion('phpredis'), '5', '>=') + ? 'del' + : 'delete'; + $CI =& get_instance(); if ($CI->config->load('redis', TRUE, TRUE)) @@ -198,7 +209,7 @@ class CI_Cache_redis extends CI_Driver */ public function delete($key) { - if ($this->_redis->delete($key) !== 1) + if ($this->_redis->{static::$_delete_name}($key) !== 1) { return FALSE; } diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 4db7ad538..89b68e118 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -12,6 +12,7 @@ Release Date: Not Released - Changed ``CI_Log`` to append ``PHP_EOL`` instead of ``\n`` at the end of log messages. - Improved performance in :doc:`Cache Library ` 'redis' driver with non-scalar variables. - Altered the :doc:`Session Library ` 'files' driver to log error and trigger a session start failure instead of throwing an ``Exception`` in case of unusable ``$config['sess_save_path']``. + - Updated the :doc:`Session ` and :doc:`Cache ` libraries' 'redis' driver to work with phpRedis 5. Bug fixes for 3.1.11 ==================== -- cgit v1.2.3-24-g4f1b