From 173f1b1b297ea161101522a71f80987576137f51 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Fri, 6 Oct 2023 10:52:48 -0400 Subject: [PATCH] Fix issue processwire/processwire-issues#1824 --- wire/core/PagesRaw.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/wire/core/PagesRaw.php b/wire/core/PagesRaw.php index d15b8f75..b8030dfb 100644 --- a/wire/core/PagesRaw.php +++ b/wire/core/PagesRaw.php @@ -861,11 +861,11 @@ class PagesRawFinder extends Wire { protected function findCustom() { if(count($this->customFields)) { // one or more custom fields requested - if($this->ids === null) { + if($this->ids === null && !empty($this->selector)) { // only find IDs if we didn’t already in the nativeFields section $this->setIds($this->findIDs($this->selector, false)); } - if(!count($this->ids)) return; + if(empty($this->ids)) return; foreach($this->customFields as $fieldName => $field) { /** @var Field $field */ $cols = isset($this->customCols[$fieldName]) ? $this->customCols[$fieldName] : array(); @@ -1144,11 +1144,12 @@ class PagesRawFinder extends Wire { $this->wire($finder); $options = $this->options; $options['indexed'] = true; - $pageRefRows = $finder->find($pageRefIds, $pageRefCols, $options); + $pageRefRows = count($pageRefIds) ? $finder->find($pageRefIds, $pageRefCols, $options) : array(); foreach($this->values as $pageId => $pageRow) { if(!isset($pageRow[$fieldName])) continue; foreach($pageRow[$fieldName] as $pageRefId) { + if(!isset($pageRefRows[$pageRefId])) continue; $this->values[$pageId][$fieldName][$pageRefId] = $pageRefRows[$pageRefId]; } if(!$this->getMultiple && $field->get('derefAsPage') > 0) {