1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-10 08:34:09 +02:00

Cache handler test added. Cache handler getLastError() method added.

This commit is contained in:
Cameron
2020-12-16 09:45:11 -08:00
parent 8e5bc7d829
commit 1c0cfbe0ff
6 changed files with 235 additions and 2 deletions

View File

@@ -31,6 +31,7 @@ class ecache {
public $CachenqMD5;
public $UserCacheActive; // Checkable flag - TRUE if user cache enabled
public $SystemCacheActive; // Checkable flag - TRUE if system cache enabled
private $lastError;
const CACHE_PREFIX = '<?php exit;';
@@ -146,6 +147,12 @@ class ecache {
else
{
$ret = file_get_contents($cache_file);
if($ret === false)
{
$this->lastError = "Couldn't read ".$cache_file;
}
if (substr($ret,0,strlen(self::CACHE_PREFIX)) == self::CACHE_PREFIX)
{
$ret = substr($ret, strlen(self::CACHE_PREFIX));
@@ -154,18 +161,28 @@ class ecache {
{
$ret = substr($ret, 5); // Handle the history for now
}
return $ret;
}
}
else
{
// e107::getDebug()->log("Couldn't find cache file: ".json_encode($cache_file));
$this->lastError = "Cache file not found: ".$cache_file;
return false;
}
}
return false;
}
/**
* Return the last error encountered during cache processing.
* @return mixed
*/
public function getLastError()
{
return $this->lastError;
}
/**
* @return string
* @param string $CacheTag
@@ -225,7 +242,7 @@ class ecache {
{
if(isset($this) && $this instanceof ecache)
{
return $this->set($CacheTag, $Data, $ForceCache, $bRaw, true);
$this->set($CacheTag, $Data, $ForceCache, $bRaw, true);
}
else
{