]> _ Git - cubist_cms-back.git/commitdiff
Fix problem with PageData get() function not returning correct data when current...
authorStephen Cameron <stephen@cubedesigners.com>
Tue, 16 Jul 2019 14:52:51 +0000 (16:52 +0200)
committerStephen Cameron <stephen@cubedesigners.com>
Tue, 16 Jul 2019 14:52:51 +0000 (16:52 +0200)
src/app/Magic/PageData.php

index f00d4b6474cc201a1eacf17d9c21b6de54111e7a..dc8a2295a2aa48742bd307bd8823fd14405b50f0 100644 (file)
@@ -84,10 +84,18 @@ class PageData implements \ArrayAccess
     public function get($offset, $default = null)
     {
         $res = Arr::get($this->_data, $offset, $default);
-        if (is_array($res) && isset($res[App::getLocale()])) {
+
+        // 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.
+        if (is_array($res) && array_key_exists(App::getLocale(), $res)) {
             $res = $res[App::getLocale()];
         }
 
+        if (!$res) {
+            return $default;
+        }
+
         return $res;
     }