summaryrefslogtreecommitdiff
path: root/inc/cache.php
diff options
context:
space:
mode:
authorAppleman1234 <applemansigloo@gmail.com>2022-09-25 13:30:13 +1000
committerAppleman1234 <applemansigloo@gmail.com>2022-09-25 13:30:13 +1000
commit2c69095a1edf7474073451285238659d0f62ce3f (patch)
tree5dee476605402c66dc2853d0836b29f6aedae62b /inc/cache.php
parente9a61e2fbbd930eaa80d6a5f33420cedc59d748c (diff)
PHP8.1 fixes from Rector
Diffstat (limited to 'inc/cache.php')
-rw-r--r--inc/cache.php14
1 files changed, 7 insertions, 7 deletions
diff --git a/inc/cache.php b/inc/cache.php
index 852aefa2..0c9bc8e2 100644
--- a/inc/cache.php
+++ b/inc/cache.php
@@ -25,7 +25,7 @@ class Cache {
self::$cache->select($config['cache']['redis'][3]) or die('cache select failure');
break;
case 'php':
- self::$cache = array();
+ self::$cache = [];
break;
}
}
@@ -48,7 +48,7 @@ class Cache {
$data = xcache_get($key);
break;
case 'php':
- $data = isset(self::$cache[$key]) ? self::$cache[$key] : false;
+ $data = self::$cache[$key] ?? false;
break;
case 'fs':
$key = str_replace('/', '::', $key);
@@ -58,13 +58,13 @@ class Cache {
}
else {
$data = file_get_contents('tmp/cache/'.$key);
- $data = json_decode($data, true);
+ $data = json_decode($data, true, 512, JSON_THROW_ON_ERROR);
}
break;
case 'redis':
if (!self::$cache)
self::init();
- $data = json_decode(self::$cache->get($key), true);
+ $data = json_decode((string) self::$cache->get($key), true, 512, JSON_THROW_ON_ERROR);
break;
}
@@ -90,7 +90,7 @@ class Cache {
case 'redis':
if (!self::$cache)
self::init();
- self::$cache->setex($key, $expires, json_encode($value));
+ self::$cache->setex($key, $expires, json_encode($value, JSON_THROW_ON_ERROR));
break;
case 'apc':
apc_store($key, $value, $expires);
@@ -101,7 +101,7 @@ class Cache {
case 'fs':
$key = str_replace('/', '::', $key);
$key = str_replace("\0", '', $key);
- file_put_contents('tmp/cache/'.$key, json_encode($value));
+ file_put_contents('tmp/cache/'.$key, json_encode($value, JSON_THROW_ON_ERROR));
break;
case 'php':
self::$cache[$key] = $value;
@@ -153,7 +153,7 @@ class Cache {
case 'apc':
return apc_clear_cache('user');
case 'php':
- self::$cache = array();
+ self::$cache = [];
break;
case 'fs':
$files = glob('tmp/cache/*');