From 09352b1514c402180d6b6fa08b04f36aad94bec9 Mon Sep 17 00:00:00 2001 From: Stephen Cameron Date: Mon, 12 Aug 2019 16:21:39 +0200 Subject: [PATCH] Ensure that empty arrays are handled properly when getting page data. WIP #2738 @1 --- src/app/Magic/PageData.php | 6 ++++++ 1 file changed, 6 insertions(+) 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. -- 2.39.5