From 5586dd074baaf9cc8722664ec689e3a886ae4538 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Thu, 26 Sep 2019 14:38:34 -0400 Subject: [PATCH] Fix issue processwire/processwire-issues#970 --- wire/core/Page.php | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/wire/core/Page.php b/wire/core/Page.php index ccfabdba..d37a1629 100644 --- a/wire/core/Page.php +++ b/wire/core/Page.php @@ -1435,25 +1435,27 @@ class Page extends WireData implements \Countable, WireMatchable { $keys = explode('|', $multiKey); foreach($keys as $key) { - $value = $this->getUnformatted($key); - - if(is_object($value)) { - // like LanguagesPageFieldValue or WireArray - $str = trim((string) $value); + $v = $this->getUnformatted($key); + + if(is_array($v) || $v instanceof WireArray) { + // array or WireArray + if(!count($v)) continue; + + } else if(is_object($v)) { + // like LanguagesPageFieldValue + $str = trim((string) $v); if(!strlen($str)) continue; - } else if(is_array($value)) { - // array with no items - if(!count($value)) continue; - - } else if(is_string($value)) { - $value = trim($value); + } else if(is_string($v)) { + $v = trim($v); } - if($value) { - if($this->outputFormatting) $value = $this->get($key); - if($value) { - if($getKey) $value = $key; + if($v) { + if($this->outputFormatting) { + $v = $this->get($key); + } + if($v) { + $value = $getKey ? $key : $v; break; } }