BUG 0000 "Displayed fatal error when PMmemcached use fileCache" SOLVED
- Displayed fatal error when PMmemcached use class.fileCache.php - Fix problem, added missing methods in class.fileCache.php * Available from version ProcessMaker-2.0.46
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class.memcached.php
|
* class.memcached.php
|
||||||
*
|
*
|
||||||
@@ -28,15 +27,14 @@
|
|||||||
|
|
||||||
class FileCache
|
class FileCache
|
||||||
{
|
{
|
||||||
|
|
||||||
function __construct ($dir)
|
function __construct ($dir)
|
||||||
{
|
{
|
||||||
$this->dir = $dir;
|
$this->dir = $dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function _name ($key)
|
private function _name($key)
|
||||||
{
|
{
|
||||||
return sprintf( "%s/%s", $this->dir, sha1( $key ) );
|
return sprintf("%s%s", $this->dir, sha1($key));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get ($key, $expiration = 3600)
|
public function get ($key, $expiration = 3600)
|
||||||
@@ -53,7 +51,7 @@ class FileCache
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (filemtime( $cache_path ) < (time() - $expiration)) {
|
if (filemtime( $cache_path ) < (time() - $expiration)) {
|
||||||
// $this->clear($key);
|
// $this->delete($key);
|
||||||
// different users can have different timeout requests
|
// different users can have different timeout requests
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@@ -102,15 +100,26 @@ class FileCache
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function clear ($key)
|
public function delete($key)
|
||||||
{
|
{
|
||||||
$cache_path = $this->_name( $key );
|
$cache_path = $this->_name($key);
|
||||||
|
|
||||||
if (file_exists( $cache_path )) {
|
if (file_exists($cache_path)) {
|
||||||
unlink( $cache_path );
|
unlink($cache_path);
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public function flush()
|
||||||
|
{
|
||||||
|
G::rm_dir($this->dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getStats()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class.memcached.php
|
* class.memcached.php
|
||||||
*
|
*
|
||||||
@@ -66,9 +65,11 @@ class PMmemcached
|
|||||||
$this->version = $this->mem->getVersion();
|
$this->version = $this->mem->getVersion();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
require_once ('classes/class.fileCache.php');
|
require_once ("classes" . PATH_SEP . "class.fileCache.php");
|
||||||
// create cache folder
|
|
||||||
$cacheFolder = PATH_DATA . "sites/" . $workspace . "/cachefiles/";
|
//Create cache folder
|
||||||
|
$cacheFolder = PATH_DATA . "sites". PATH_SEP . $workspace . PATH_SEP . "cachefiles" . PATH_SEP;
|
||||||
|
|
||||||
if (! file_exists( $cacheFolder )) {
|
if (! file_exists( $cacheFolder )) {
|
||||||
if (! mkdir( $cacheFolder )) {
|
if (! mkdir( $cacheFolder )) {
|
||||||
return false;
|
return false;
|
||||||
@@ -116,7 +117,8 @@ class PMmemcached
|
|||||||
if (! $this->connected) {
|
if (! $this->connected) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ($this->class != 'filecache') {
|
|
||||||
|
if ($this->class != "fileCache") {
|
||||||
$this->mem->set( $this->workspace . '_' . $key, $object, false, $timeout );
|
$this->mem->set( $this->workspace . '_' . $key, $object, false, $timeout );
|
||||||
} else {
|
} else {
|
||||||
$this->mem->set( $this->workspace . '_' . $key, $object );
|
$this->mem->set( $this->workspace . '_' . $key, $object );
|
||||||
@@ -133,50 +135,61 @@ class PMmemcached
|
|||||||
|
|
||||||
public function add ($key, $value)
|
public function add ($key, $value)
|
||||||
{
|
{
|
||||||
if ((! $this->connected) || ($this->class == 'filecache')) {
|
if (!$this->connected || $this->class == "fileCache") {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->mem->add( $this->workspace . '_' . $key, $value );
|
return $this->mem->add( $this->workspace . '_' . $key, $value );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function increment ($key, $value)
|
public function increment ($key, $value)
|
||||||
{
|
{
|
||||||
if ((! $this->connected) || ($this->class == 'filecache')) {
|
if (!$this->connected || $this->class == "fileCache") {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->mem->increment( $this->workspace . '_' . $key, $value );
|
return $this->mem->increment( $this->workspace . '_' . $key, $value );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete ($key)
|
public function delete($key)
|
||||||
{
|
{
|
||||||
if ((! $this->connected) || ($this->class == 'filecache')) {
|
if (!$this->connected) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return $this->mem->delete( $this->workspace . '_' . $key );
|
|
||||||
|
return $this->mem->delete($this->workspace . "_" . $key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function flush ()
|
public function flush()
|
||||||
{
|
{
|
||||||
if ((! $this->connected) || ($this->class == 'filecache')) {
|
if (!$this->connected) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->mem->flush();
|
return $this->mem->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStats ()
|
public function getStats()
|
||||||
{
|
{
|
||||||
if ((! $this->connected) || ($this->class == 'filecache')) {
|
if (!$this->connected) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $status = $this->mem->getStats();
|
return $status = $this->mem->getStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function printDetails ()
|
public function printDetails()
|
||||||
{
|
{
|
||||||
if ((! $this->connected) || ($this->class == 'filecache')) {
|
if (!$this->connected) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$status = $this->mem->getStats();
|
$status = $this->mem->getStats();
|
||||||
|
|
||||||
|
if (!is_array($status)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
echo "<table border='1'>";
|
echo "<table border='1'>";
|
||||||
echo "<tr><td>Memcache Server version:</td><td> " . $status["version"] . "</td></tr>";
|
echo "<tr><td>Memcache Server version:</td><td> " . $status["version"] . "</td></tr>";
|
||||||
echo "<tr><td>Number of hours this server has been running </td><td>" . ($status["uptime"] / 3660) . "</td></tr>";
|
echo "<tr><td>Number of hours this server has been running </td><td>" . ($status["uptime"] / 3660) . "</td></tr>";
|
||||||
|
|||||||
Reference in New Issue
Block a user