From: Stephen Cameron Date: Tue, 16 Jul 2019 14:52:51 +0000 (+0200) Subject: Fix problem with PageData get() function not returning correct data when current... X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=596ba579d1086a384c9b218ff476cb4a0c398c03;p=cubist_cms-back.git Fix problem with PageData get() function not returning correct data when current translation value is null. WIP #2738 @1 --- diff --git a/src/app/Magic/PageData.php b/src/app/Magic/PageData.php index f00d4b6..dc8a229 100644 --- a/src/app/Magic/PageData.php +++ b/src/app/Magic/PageData.php @@ -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; }