diff --git a/plugins/DiskCache/DiskCachePlugin.php b/plugins/DiskCache/DiskCachePlugin.php
index 3d6a0115db..b7b6ce5494 100644
--- a/plugins/DiskCache/DiskCachePlugin.php
+++ b/plugins/DiskCache/DiskCachePlugin.php
@@ -1,56 +1,47 @@
.
+
/**
- * StatusNet - the distributed open-source microblogging tool
- * Copyright (C) 2009, StatusNet, Inc.
- *
* Plugin to implement cache interface with disk files
*
- * PHP version 5
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- *
* @category Cache
- * @package StatusNet
+ * @package GNUsocial
* @author Evan Prodromou
* @copyright 2009 StatusNet, Inc.
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://status.net/
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
-if (!defined('STATUSNET')) {
- // This check helps protect against security problems;
- // your code file can't be executed directly from the web.
- exit(1);
-}
+defined('GNUSOCIAL') || die();
/**
* A plugin to cache data on local disk
*
* @category Cache
- * @package StatusNet
+ * @package GNUsocial
* @author Evan Prodromou
* @copyright 2009 StatusNet, Inc.
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://status.net/
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
class DiskCachePlugin extends Plugin
{
const PLUGIN_VERSION = '2.0.0';
- var $root = '/tmp';
+ public $root = '/tmp';
- function keyToFilename($key)
+ public function keyToFilename($key)
{
return $this->root . '/' . str_replace(':', '/', $key);
}
@@ -65,17 +56,27 @@ class DiskCachePlugin extends Plugin
*
* @return boolean hook success
*/
- function onStartCacheGet(&$key, &$value)
+ public function onStartCacheGet(&$key, &$value)
{
$filename = $this->keyToFilename($key);
+ $data = false;
if (file_exists($filename)) {
$data = file_get_contents($filename);
- if ($data !== false) {
- $value = unserialize($data);
- }
}
+ if ($data === false) {
+ return true;
+ }
+
+ $ret = unserialize($data);
+
+ if ($ret === false && $data !== 'b:0;') {
+ common_log(LOG_ERR, 'DiskCache could not handle: ' . $data);
+ return true;
+ }
+
+ $value = $ret;
return false;
}
@@ -90,7 +91,7 @@ class DiskCachePlugin extends Plugin
*
* @return boolean hook success
*/
- function onStartCacheSet(&$key, &$value, &$flag, &$expiry, &$success)
+ public function onStartCacheSet(&$key, &$value, &$flag, &$expiry, &$success)
{
$filename = $this->keyToFilename($key);
$parent = dirname($filename);
@@ -147,7 +148,7 @@ class DiskCachePlugin extends Plugin
*
* @return boolean hook success
*/
- function onStartCacheDelete(&$key, &$success)
+ public function onStartCacheDelete(&$key, &$success)
{
$filename = $this->keyToFilename($key);
diff --git a/plugins/RedisCache/RedisCachePlugin.php b/plugins/RedisCache/RedisCachePlugin.php
index 7ae7b3cffa..d544355426 100644
--- a/plugins/RedisCache/RedisCachePlugin.php
+++ b/plugins/RedisCache/RedisCachePlugin.php
@@ -15,7 +15,7 @@
// along with GNU social. If not, see .
/**
- * Plguin inplementing Redis based caching
+ * Plugin inplementing Redis based caching
*
* @category Files
* @package GNUsocial
@@ -58,21 +58,28 @@ class RedisCachePlugin extends Plugin
{
try {
$this->_ensureConn();
- $ret = $this->client->get($key);
+ $data = $this->client->get($key);
} catch (PredisException $e) {
common_log(LOG_ERR, 'RedisCache encountered exception ' . get_class($e) . ': ' . $e->getMessage());
return true;
}
- // Hit, overwrite "value" and return false
- // to indicate we took care of this
- if ($ret !== null) {
- $value = unserialize($ret);
- return false;
+ if (is_null($data)) {
+ // Miss, let GS do its thing
+ return true;
}
- // Miss, let GS do its thing
- return true;
+ $ret = unserialize($data);
+
+ if ($ret === false && $data !== 'b:0;') {
+ common_log(LOG_ERR, 'RedisCache could not handle: ' . $data);
+ return true;
+ }
+
+ // Hit, overwrite "value" and return false
+ // to indicate we took care of this
+ $value = $ret;
+ return false;
}
public function onStartCacheSet($key, $value, $flag, $expiry, &$success)