From f7d0e4530c58e396a47ec67dfed9cf564fc5fd32 Mon Sep 17 00:00:00 2001 From: onli Date: Fri, 5 Mar 2021 08:21:36 +0100 Subject: [PATCH] Update Cache-Lite to 1.8.3 Compatibility with PHP 7.4 --- bundled-libs/Cache/Lite.php | 18 +++++++++++++++--- bundled-libs/Cache/Lite/File.php | 10 ++++++++++ bundled-libs/Cache/Lite/Function.php | 12 +++++++++++- bundled-libs/Cache/Lite/Output.php | 10 ++++++++++ 4 files changed, 46 insertions(+), 4 deletions(-) diff --git a/bundled-libs/Cache/Lite.php b/bundled-libs/Cache/Lite.php index 5770f3d1..18e6b832 100644 --- a/bundled-libs/Cache/Lite.php +++ b/bundled-libs/Cache/Lite.php @@ -303,6 +303,16 @@ class Cache_Lite $this->setOption('cacheDir', sys_get_temp_dir() . DIRECTORY_SEPARATOR); } } + + /** + * PHP4 constructor for backwards compatibility with older code + * + * @param array $options Options + */ + function Cache_Lite($options = array(NULL)) + { + self::__construct($options); + } /** * Generic way to set a Cache_Lite option @@ -698,8 +708,10 @@ class Cache_Lite $this->_touchCacheFile(); $this->_memoryCachingArray[$this->_file] = $data; if ($this->_memoryCachingCounter >= $this->_memoryCachingLimit) { - list($key, ) = each($this->_memoryCachingArray); + $key = key($this->_memoryCachingArray); + next($this->_memoryCachingArray); unset($this->_memoryCachingArray[$key]); + } else { $this->_memoryCachingCounter = $this->_memoryCachingCounter + 1; } @@ -744,7 +756,7 @@ class Cache_Lite if ($this->_fileLocking) @flock($fp, LOCK_SH); clearstatcache(); $length = @filesize($this->_file); - $mqr = get_magic_quotes_runtime(); + $mqr = (function_exists('get_magic_quotes_runtime') ? @get_magic_quotes_runtime() : 0); if ($mqr) { set_magic_quotes_runtime(0); } @@ -823,7 +835,7 @@ class Cache_Lite if ($this->_readControl) { @fwrite($fp, $this->_hash($data, $this->_readControlType), 32); } - $mqr = get_magic_quotes_runtime(); + $mqr = (function_exists('get_magic_quotes_runtime') ? @get_magic_quotes_runtime() : 0); if ($mqr) { set_magic_quotes_runtime(0); } diff --git a/bundled-libs/Cache/Lite/File.php b/bundled-libs/Cache/Lite/File.php index d8ca31c1..c732d743 100644 --- a/bundled-libs/Cache/Lite/File.php +++ b/bundled-libs/Cache/Lite/File.php @@ -65,6 +65,16 @@ class Cache_Lite_File extends Cache_Lite return $this->raiseError('Cache_Lite_File : Unable to read masterFile : '.$this->_masterFile, -3); } } + + /** + * PHP4 constructor for backwards compatibility with older code + * + * @param array $options Options + */ + function Cache_Lite_File($options = array(NULL)) + { + self::__construct($options); + } /** * Test if a cache is available and (if yes) return it diff --git a/bundled-libs/Cache/Lite/Function.php b/bundled-libs/Cache/Lite/Function.php index 0814b58f..2e5ecada 100644 --- a/bundled-libs/Cache/Lite/Function.php +++ b/bundled-libs/Cache/Lite/Function.php @@ -84,7 +84,7 @@ class Cache_Lite_Function extends Cache_Lite function __construct($options = array(NULL)) { $availableOptions = array('debugCacheLiteFunction', 'defaultGroup', 'dontCacheWhenTheOutputContainsNOCACHE', 'dontCacheWhenTheResultIsFalse', 'dontCacheWhenTheResultIsNull'); - while (list($name, $value) = each($options)) { + foreach ($options as $name => $value) { if (in_array($name, $availableOptions)) { $property = '_'.$name; $this->$property = $value; @@ -94,6 +94,16 @@ class Cache_Lite_Function extends Cache_Lite parent::__construct($options); } + /** + * PHP4 constructor for backwards compatibility with older code + * + * @param array $options Options + */ + function Cache_Lite_Function($options = array(NULL)) + { + self::__construct($options); + } + /** * Calls a cacheable function or method (or not if there is already a cache for it) * diff --git a/bundled-libs/Cache/Lite/Output.php b/bundled-libs/Cache/Lite/Output.php index 9880cfa4..579c71b3 100644 --- a/bundled-libs/Cache/Lite/Output.php +++ b/bundled-libs/Cache/Lite/Output.php @@ -31,6 +31,16 @@ class Cache_Lite_Output extends Cache_Lite parent::__construct($options); } + /** + * PHP4 constructor for backwards compatibility with older code + * + * @param array $options Options + */ + function Cache_Lite_Output($options = array(NULL)) + { + self::__construct($options); + } + /** * Start the cache *