]> _ Git - cubist_cms-back.git/commitdiff
Ensure that empty arrays are handled properly when getting page data. WIP #2738 @1
authorStephen Cameron <stephen@cubedesigners.com>
Mon, 12 Aug 2019 14:21:39 +0000 (16:21 +0200)
committerStephen Cameron <stephen@cubedesigners.com>
Mon, 12 Aug 2019 14:21:39 +0000 (16:21 +0200)
src/app/Magic/PageData.php

index e6fc52d875c6811d314600139a7984524fb3e1bc..57b8d0aae3d9a49a668ae4bb53a9c541d7d40a6a 100644 (file)
@@ -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.