From be59f15252968c1158e5be57194a9dd02c7f9930 Mon Sep 17 00:00:00 2001 From: "B. Endres" Date: Mon, 7 Jun 2021 11:51:15 +0200 Subject: [PATCH] [#52] updated CacheLite to v1.8.3 --- proxy/libs/Cache/Lite.php | 20 ++++++++++++++++---- proxy/libs/Cache/Lite/File.php | 14 ++++++++++++-- proxy/libs/Cache/Lite/Function.php | 16 +++++++++++++--- proxy/libs/Cache/Lite/Output.php | 14 ++++++++++++-- proxy/libs/Cache/README.md | 28 +++++++++++++++++++++++----- 5 files changed, 76 insertions(+), 16 deletions(-) diff --git a/proxy/libs/Cache/Lite.php b/proxy/libs/Cache/Lite.php index 0ca762d..18e6b83 100644 --- a/proxy/libs/Cache/Lite.php +++ b/proxy/libs/Cache/Lite.php @@ -294,7 +294,7 @@ class Cache_Lite * @param array $options options * @access public */ - function Cache_Lite($options = array(NULL)) + function __construct($options = array(NULL)) { foreach($options as $key => $value) { $this->setOption($key, $value); @@ -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/proxy/libs/Cache/Lite/File.php b/proxy/libs/Cache/Lite/File.php index 2cb2758..c732d74 100644 --- a/proxy/libs/Cache/Lite/File.php +++ b/proxy/libs/Cache/Lite/File.php @@ -52,10 +52,10 @@ class Cache_Lite_File extends Cache_Lite * @param array $options options * @access public */ - function Cache_Lite_File($options = array(NULL)) + function __construct($options = array(NULL)) { $options['lifetime'] = 0; - $this->Cache_Lite($options); + parent::__construct($options); if (isset($options['masterFile'])) { $this->_masterFile = $options['masterFile']; } else { @@ -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/proxy/libs/Cache/Lite/Function.php b/proxy/libs/Cache/Lite/Function.php index 6c4861a..2e5ecad 100644 --- a/proxy/libs/Cache/Lite/Function.php +++ b/proxy/libs/Cache/Lite/Function.php @@ -81,17 +81,27 @@ class Cache_Lite_Function extends Cache_Lite * @param array $options options * @access public */ - function Cache_Lite_Function($options = array(NULL)) + 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; } } reset($options); - $this->Cache_Lite($options); + 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); } /** diff --git a/proxy/libs/Cache/Lite/Output.php b/proxy/libs/Cache/Lite/Output.php index 87d7c19..579c71b 100644 --- a/proxy/libs/Cache/Lite/Output.php +++ b/proxy/libs/Cache/Lite/Output.php @@ -26,9 +26,19 @@ class Cache_Lite_Output extends Cache_Lite * @param array $options options * @access public */ - function Cache_Lite_Output($options) + function __construct($options) { - $this->Cache_Lite($options); + 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); } /** diff --git a/proxy/libs/Cache/README.md b/proxy/libs/Cache/README.md index 0a6577d..bb1b4e6 100644 --- a/proxy/libs/Cache/README.md +++ b/proxy/libs/Cache/README.md @@ -1,19 +1,25 @@ # PEAR Cache_Lite +Fast and safe little cache system. + +This package is a little cache system optimized for file containers. +t is fast and safe (because it uses file locking and/or anti-corruption tests). + [![Build Status](https://travis-ci.org/pear/Cache_Lite.svg)](https://travis-ci.org/pear/Cache_Lite) -This package is [Cache_Lite](http://pear.php.net/package/Cache_Lite). - -Please report all new issues via the [PEAR bug tracker](http://pear.php.net/bugs/). +## Building To test this package, run - + phpunit tests/ -To build, simply +To build, simply execute pear package + +## Installation +### PEAR To install from scratch pear install package.xml @@ -21,3 +27,15 @@ To install from scratch To upgrade pear upgrade -f package.xml + +### Composer + + composer require pear/cache_lite + + +## Links +- Homepage: http://pear.php.net/package/Cache_Lite +- Source code: https://github.com/pear/Cache_Lite +- Issue tracker: http://pear.php.net/bugs/search.php?cmd=display&package_name[]=Cache_Lite +- Unit test status: https://travis-ci.org/pear/Cache_Lite +- Packagist: https://packagist.org/packages/pear/cache_lite