Update Cache-Lite to 1.8.3

Compatibility with PHP 7.4
This commit is contained in:
onli 2021-03-05 08:21:36 +01:00
parent 54efde550e
commit f7d0e4530c
4 changed files with 46 additions and 4 deletions

View File

@ -303,6 +303,16 @@ class Cache_Lite
$this->setOption('cacheDir', sys_get_temp_dir() . DIRECTORY_SEPARATOR); $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 * Generic way to set a Cache_Lite option
@ -698,8 +708,10 @@ class Cache_Lite
$this->_touchCacheFile(); $this->_touchCacheFile();
$this->_memoryCachingArray[$this->_file] = $data; $this->_memoryCachingArray[$this->_file] = $data;
if ($this->_memoryCachingCounter >= $this->_memoryCachingLimit) { if ($this->_memoryCachingCounter >= $this->_memoryCachingLimit) {
list($key, ) = each($this->_memoryCachingArray); $key = key($this->_memoryCachingArray);
next($this->_memoryCachingArray);
unset($this->_memoryCachingArray[$key]); unset($this->_memoryCachingArray[$key]);
} else { } else {
$this->_memoryCachingCounter = $this->_memoryCachingCounter + 1; $this->_memoryCachingCounter = $this->_memoryCachingCounter + 1;
} }
@ -744,7 +756,7 @@ class Cache_Lite
if ($this->_fileLocking) @flock($fp, LOCK_SH); if ($this->_fileLocking) @flock($fp, LOCK_SH);
clearstatcache(); clearstatcache();
$length = @filesize($this->_file); $length = @filesize($this->_file);
$mqr = get_magic_quotes_runtime(); $mqr = (function_exists('get_magic_quotes_runtime') ? @get_magic_quotes_runtime() : 0);
if ($mqr) { if ($mqr) {
set_magic_quotes_runtime(0); set_magic_quotes_runtime(0);
} }
@ -823,7 +835,7 @@ class Cache_Lite
if ($this->_readControl) { if ($this->_readControl) {
@fwrite($fp, $this->_hash($data, $this->_readControlType), 32); @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) { if ($mqr) {
set_magic_quotes_runtime(0); set_magic_quotes_runtime(0);
} }

View File

@ -65,6 +65,16 @@ class Cache_Lite_File extends Cache_Lite
return $this->raiseError('Cache_Lite_File : Unable to read masterFile : '.$this->_masterFile, -3); 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 * Test if a cache is available and (if yes) return it

View File

@ -84,7 +84,7 @@ class Cache_Lite_Function extends Cache_Lite
function __construct($options = array(NULL)) function __construct($options = array(NULL))
{ {
$availableOptions = array('debugCacheLiteFunction', 'defaultGroup', 'dontCacheWhenTheOutputContainsNOCACHE', 'dontCacheWhenTheResultIsFalse', 'dontCacheWhenTheResultIsNull'); $availableOptions = array('debugCacheLiteFunction', 'defaultGroup', 'dontCacheWhenTheOutputContainsNOCACHE', 'dontCacheWhenTheResultIsFalse', 'dontCacheWhenTheResultIsNull');
while (list($name, $value) = each($options)) { foreach ($options as $name => $value) {
if (in_array($name, $availableOptions)) { if (in_array($name, $availableOptions)) {
$property = '_'.$name; $property = '_'.$name;
$this->$property = $value; $this->$property = $value;
@ -94,6 +94,16 @@ class Cache_Lite_Function extends Cache_Lite
parent::__construct($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);
}
/** /**
* Calls a cacheable function or method (or not if there is already a cache for it) * Calls a cacheable function or method (or not if there is already a cache for it)
* *

View File

@ -31,6 +31,16 @@ class Cache_Lite_Output extends Cache_Lite
parent::__construct($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);
}
/** /**
* Start the cache * Start the cache
* *