Address serialize/unserialize issues
This will require a cache clear for the combiner Ref https://davidwalsh.name/php-serialize-unserialize-issues
This commit is contained in:
parent
cb6cf45156
commit
87a4de40de
|
|
@ -229,7 +229,7 @@ abstract class WidgetBase
|
||||||
$currentStore = $this->getSession();
|
$currentStore = $this->getSession();
|
||||||
$currentStore[$key] = $value;
|
$currentStore[$key] = $value;
|
||||||
|
|
||||||
Session::put($sessionId, serialize($currentStore));
|
Session::put($sessionId, base64_encode(serialize($currentStore)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -241,10 +241,13 @@ abstract class WidgetBase
|
||||||
protected function getSession($key = null, $default = null)
|
protected function getSession($key = null, $default = null)
|
||||||
{
|
{
|
||||||
$sessionId = $this->makeSessionId();
|
$sessionId = $this->makeSessionId();
|
||||||
|
|
||||||
$currentStore = [];
|
$currentStore = [];
|
||||||
if (Session::has($sessionId)) {
|
|
||||||
$currentStore = unserialize(Session::get($sessionId));
|
if (
|
||||||
|
Session::has($sessionId) &&
|
||||||
|
($cached = @unserialize(@base64_decode(Session::get($sessionId)))) !== false
|
||||||
|
) {
|
||||||
|
$currentStore = $cached;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($key === null) {
|
if ($key === null) {
|
||||||
|
|
|
||||||
|
|
@ -268,7 +268,7 @@ class CmsCompoundObject extends CmsObject
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$cached = Cache::get($key, false);
|
$cached = Cache::get($key, false);
|
||||||
$unserialized = $cached ? @unserialize($cached) : false;
|
$unserialized = $cached ? @unserialize(@base64_decode($cached)) : false;
|
||||||
$objectComponentMap = $unserialized ? $unserialized : [];
|
$objectComponentMap = $unserialized ? $unserialized : [];
|
||||||
if ($objectComponentMap) {
|
if ($objectComponentMap) {
|
||||||
self::$objectComponentPropertyMap = $objectComponentMap;
|
self::$objectComponentPropertyMap = $objectComponentMap;
|
||||||
|
|
@ -312,7 +312,7 @@ class CmsCompoundObject extends CmsObject
|
||||||
|
|
||||||
self::$objectComponentPropertyMap = $objectComponentMap;
|
self::$objectComponentPropertyMap = $objectComponentMap;
|
||||||
|
|
||||||
Cache::put($key, serialize($objectComponentMap), Config::get('cms.parsedPageCacheTTL', 10));
|
Cache::put($key, base64_encode(serialize($objectComponentMap)), Config::get('cms.parsedPageCacheTTL', 10));
|
||||||
|
|
||||||
if (array_key_exists($componentName, $objectComponentMap[$objectCode])) {
|
if (array_key_exists($componentName, $objectComponentMap[$objectCode])) {
|
||||||
return $objectComponentMap[$objectCode][$componentName];
|
return $objectComponentMap[$objectCode][$componentName];
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ class CodeParser
|
||||||
$cacheItem['mtime'] = $this->object->mtime;
|
$cacheItem['mtime'] = $this->object->mtime;
|
||||||
$cached[$this->filePath] = $cacheItem;
|
$cached[$this->filePath] = $cacheItem;
|
||||||
|
|
||||||
Cache::put($this->dataCacheKey, serialize($cached), 1440);
|
Cache::put($this->dataCacheKey, base64_encode(serialize($cached)), 1440);
|
||||||
|
|
||||||
return self::$cache[$this->filePath] = $result;
|
return self::$cache[$this->filePath] = $result;
|
||||||
}
|
}
|
||||||
|
|
@ -171,6 +171,7 @@ class CodeParser
|
||||||
protected function handleCorruptCache()
|
protected function handleCorruptCache()
|
||||||
{
|
{
|
||||||
$path = $this->getFilePath();
|
$path = $this->getFilePath();
|
||||||
|
|
||||||
if (File::isFile($path)) {
|
if (File::isFile($path)) {
|
||||||
File::delete($path);
|
File::delete($path);
|
||||||
}
|
}
|
||||||
|
|
@ -211,7 +212,11 @@ class CodeParser
|
||||||
protected function getCachedInfo()
|
protected function getCachedInfo()
|
||||||
{
|
{
|
||||||
$cached = Cache::get($this->dataCacheKey, false);
|
$cached = Cache::get($this->dataCacheKey, false);
|
||||||
if ($cached !== false && ($cached = @unserialize($cached)) !== false) {
|
|
||||||
|
if (
|
||||||
|
$cached !== false &&
|
||||||
|
($cached = @unserialize(@base64_decode($cached))) !== false
|
||||||
|
) {
|
||||||
return $cached;
|
return $cached;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -225,6 +230,7 @@ class CodeParser
|
||||||
protected function getCachedFileInfo()
|
protected function getCachedFileInfo()
|
||||||
{
|
{
|
||||||
$cached = $this->getCachedInfo();
|
$cached = $this->getCachedInfo();
|
||||||
|
|
||||||
if ($cached !== null) {
|
if ($cached !== null) {
|
||||||
if (array_key_exists($this->filePath, $cached)) {
|
if (array_key_exists($this->filePath, $cached)) {
|
||||||
return $cached[$this->filePath];
|
return $cached[$this->filePath];
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ class MediaLibrary
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$cached = Cache::get('cms-media-library-contents', false);
|
$cached = Cache::get('cms-media-library-contents', false);
|
||||||
$cached = $cached ? @unserialize($cached) : [];
|
$cached = $cached ? @unserialize(@base64_decode($cached)) : [];
|
||||||
|
|
||||||
if (!is_array($cached)) {
|
if (!is_array($cached)) {
|
||||||
$cached = [];
|
$cached = [];
|
||||||
|
|
@ -101,7 +101,11 @@ class MediaLibrary
|
||||||
$folderContents = $this->scanFolderContents($fullFolderPath);
|
$folderContents = $this->scanFolderContents($fullFolderPath);
|
||||||
|
|
||||||
$cached[$fullFolderPath] = $folderContents;
|
$cached[$fullFolderPath] = $folderContents;
|
||||||
Cache::put(self::CACHE_KEY, serialize($cached), Config::get('cms.storage.media.ttl', 10));
|
Cache::put(
|
||||||
|
self::CACHE_KEY,
|
||||||
|
base64_encode(serialize($cached)),
|
||||||
|
Config::get('cms.storage.media.ttl', 10)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,11 @@ class Router
|
||||||
: $fileName;
|
: $fileName;
|
||||||
|
|
||||||
$key = $this->getUrlListCacheKey();
|
$key = $this->getUrlListCacheKey();
|
||||||
Cache::put($key, serialize($urlList), Config::get('cms.urlCacheTtl', 1));
|
Cache::put(
|
||||||
|
$key,
|
||||||
|
base64_encode(serialize($urlList)),
|
||||||
|
Config::get('cms.urlCacheTtl', 1)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -221,7 +225,7 @@ class Router
|
||||||
$cached = false;
|
$cached = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$cached || ($unserialized = @unserialize($cached)) === false) {
|
if (!$cached || ($unserialized = @unserialize(@base64_decode($cached))) === false) {
|
||||||
/*
|
/*
|
||||||
* The item doesn't exist in the cache, create the map
|
* The item doesn't exist in the cache, create the map
|
||||||
*/
|
*/
|
||||||
|
|
@ -237,7 +241,7 @@ class Router
|
||||||
|
|
||||||
$this->urlMap = $map;
|
$this->urlMap = $map;
|
||||||
if ($cacheable) {
|
if ($cacheable) {
|
||||||
Cache::put($key, serialize($map), Config::get('cms.urlCacheTtl', 1));
|
Cache::put($key, base64_encode(serialize($map)), Config::get('cms.urlCacheTtl', 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -327,7 +331,11 @@ class Router
|
||||||
$key = $this->getUrlListCacheKey();
|
$key = $this->getUrlListCacheKey();
|
||||||
$urlList = Cache::get($key, false);
|
$urlList = Cache::get($key, false);
|
||||||
|
|
||||||
if ($urlList && ($urlList = @unserialize($urlList)) && is_array($urlList)) {
|
if (
|
||||||
|
$urlList &&
|
||||||
|
($urlList = @unserialize(@base64_decode($urlList))) &&
|
||||||
|
is_array($urlList)
|
||||||
|
) {
|
||||||
if (array_key_exists($url, $urlList)) {
|
if (array_key_exists($url, $urlList)) {
|
||||||
return $urlList[$url];
|
return $urlList[$url];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -293,7 +293,7 @@ class AssetList extends WidgetBase
|
||||||
$this->listDestinationDirectories($directories, $selectedList);
|
$this->listDestinationDirectories($directories, $selectedList);
|
||||||
|
|
||||||
$this->vars['directories'] = $directories;
|
$this->vars['directories'] = $directories;
|
||||||
$this->vars['selectedList'] = serialize(array_keys($selectedList));
|
$this->vars['selectedList'] = base64_encode(serialize(array_keys($selectedList)));
|
||||||
return $this->makePartial('move_form');
|
return $this->makePartial('move_form');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -316,7 +316,7 @@ class AssetList extends WidgetBase
|
||||||
throw new ApplicationException(Lang::get('cms::lang.asset.destination_not_found'));
|
throw new ApplicationException(Lang::get('cms::lang.asset.destination_not_found'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$list = @unserialize($selectedList);
|
$list = @unserialize(@base64_decode($selectedList));
|
||||||
if ($list === false) {
|
if ($list === false) {
|
||||||
throw new ApplicationException(Lang::get('cms::lang.asset.selected_files_not_found'));
|
throw new ApplicationException(Lang::get('cms::lang.asset.selected_files_not_found'));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -167,7 +167,7 @@ class CombineAssets
|
||||||
{
|
{
|
||||||
$cacheInfo = $this->getCache($cacheId);
|
$cacheInfo = $this->getCache($cacheId);
|
||||||
if (!$cacheInfo) {
|
if (!$cacheInfo) {
|
||||||
throw new ApplicationException(Lang::get('cms::lang.combiner.not_found', ['name'=>$cacheId]));
|
throw new ApplicationException(Lang::get('system::lang.combiner.not_found', ['name'=>$cacheId]));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->localPath = $cacheInfo['path'];
|
$this->localPath = $cacheInfo['path'];
|
||||||
|
|
@ -615,7 +615,7 @@ class CombineAssets
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->putCacheIndex($cacheId);
|
$this->putCacheIndex($cacheId);
|
||||||
Cache::forever($cacheId, serialize($cacheInfo));
|
Cache::forever($cacheId, base64_encode(serialize($cacheInfo)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -632,7 +632,7 @@ class CombineAssets
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return unserialize(Cache::get($cacheId));
|
return @unserialize(@base64_decode(Cache::get($cacheId)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -655,7 +655,8 @@ class CombineAssets
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$index = unserialize(Cache::get('combiner.index'));
|
$index = (array) @unserialize(@base64_decode(Cache::get('combiner.index'))) ?: [];
|
||||||
|
|
||||||
foreach ($index as $cacheId) {
|
foreach ($index as $cacheId) {
|
||||||
Cache::forget($cacheId);
|
Cache::forget($cacheId);
|
||||||
}
|
}
|
||||||
|
|
@ -674,7 +675,7 @@ class CombineAssets
|
||||||
$index = [];
|
$index = [];
|
||||||
|
|
||||||
if (Cache::has('combiner.index')) {
|
if (Cache::has('combiner.index')) {
|
||||||
$index = unserialize(Cache::get('combiner.index'));
|
$index = (array) @unserialize(@base64_decode(Cache::get('combiner.index'))) ?: [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array($cacheId, $index)) {
|
if (in_array($cacheId, $index)) {
|
||||||
|
|
@ -683,7 +684,8 @@ class CombineAssets
|
||||||
|
|
||||||
$index[] = $cacheId;
|
$index[] = $cacheId;
|
||||||
|
|
||||||
Cache::forever('combiner.index', serialize($index));
|
Cache::forever('combiner.index', base64_encode(serialize($index)));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -637,11 +637,11 @@ class UpdateManager
|
||||||
$cacheKey = 'system-updates-popular-'.$type;
|
$cacheKey = 'system-updates-popular-'.$type;
|
||||||
|
|
||||||
if (Cache::has($cacheKey)) {
|
if (Cache::has($cacheKey)) {
|
||||||
return @unserialize(Cache::get($cacheKey)) ?: [];
|
return @unserialize(@base64_decode(Cache::get($cacheKey))) ?: [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = $this->requestServerData($type.'/popular');
|
$data = $this->requestServerData($type.'/popular');
|
||||||
Cache::put($cacheKey, serialize($data), 60);
|
Cache::put($cacheKey, base64_encode(serialize($data)), 60);
|
||||||
|
|
||||||
foreach ($data as $product) {
|
foreach ($data as $product) {
|
||||||
$code = array_get($product, 'code', -1);
|
$code = array_get($product, 'code', -1);
|
||||||
|
|
@ -659,7 +659,7 @@ class UpdateManager
|
||||||
$cacheKey = 'system-updates-product-details';
|
$cacheKey = 'system-updates-product-details';
|
||||||
|
|
||||||
if (Cache::has($cacheKey)) {
|
if (Cache::has($cacheKey)) {
|
||||||
$this->productCache = @unserialize(Cache::get($cacheKey)) ?: $defaultCache;
|
$this->productCache = @unserialize(@base64_decode(Cache::get($cacheKey))) ?: $defaultCache;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$this->productCache = $defaultCache;
|
$this->productCache = $defaultCache;
|
||||||
|
|
@ -674,7 +674,7 @@ class UpdateManager
|
||||||
|
|
||||||
$cacheKey = 'system-updates-product-details';
|
$cacheKey = 'system-updates-product-details';
|
||||||
$expiresAt = Carbon::now()->addDays(2);
|
$expiresAt = Carbon::now()->addDays(2);
|
||||||
Cache::put($cacheKey, serialize($this->productCache), $expiresAt);
|
Cache::put($cacheKey, base64_encode(serialize($this->productCache)), $expiresAt);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function cacheProductDetail($type, $code, $data)
|
protected function cacheProductDetail($type, $code, $data)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue