From: Stephen Cameron Date: Mon, 12 Aug 2019 14:21:39 +0000 (+0200) Subject: Ensure that empty arrays are handled properly when getting page data. WIP #2738 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=09352b1514c402180d6b6fa08b04f36aad94bec9;p=cubist_cms-back.git Ensure that empty arrays are handled properly when getting page data. WIP #2738 @1 --- diff --git a/src/app/Magic/PageData.php b/src/app/Magic/PageData.php index e6fc52d..57b8d0a 100644 --- a/src/app/Magic/PageData.php +++ b/src/app/Magic/PageData.php @@ -85,6 +85,12 @@ class PageData implements \ArrayAccess { $res = Arr::get($this->_data, $offset, $default); + // If an array value is saved without any items, it might be returned + // as a string "[]" when instead it should be an empty array... + if ($res === '[]') { + $res = []; + } + // Get the translated value if the array contains a key matching the locale. // We have to check if the key exists because the actual value may be null. // Using isset() on the locale key would give a false negative if the value is null.