From 9ba7844a5dddfcbf78181b8867ca06ba4006016a Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Sun, 22 Aug 2021 08:25:45 -0400 Subject: [PATCH] Fix "OR-condition not allowed" error introduced from a change related to processwire/processwire-issues#1428 --- wire/core/PageFinder.php | 21 +++++++++++++++---- .../InputfieldSelector.module | 4 ++-- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/wire/core/PageFinder.php b/wire/core/PageFinder.php index af2b591d..6fc02f63 100644 --- a/wire/core/PageFinder.php +++ b/wire/core/PageFinder.php @@ -456,14 +456,26 @@ class PageFinder extends Wire { $checkAccessSpecified = false; $hasParents = array(); // requests for parent(s) in the selector $hasSort = false; // whether or not a sort is requested + $noArrayFields = array_flip(array( // field names that do not accept array values + 'status', + 'include', + 'check_access', + 'checkAccess', + 'limit', + 'start', + 'getTotal', + 'get_total', + )); foreach($selectors as $key => $selector) { /** @var Selector $selector */ - $fieldName = $selector->field; - - if(is_array($fieldName) || is_array($selector->value)) { - throw new PageFinderException("OR-condition not supported in '$selector'"); + $fieldName = $selector->field(); + + if(isset($noArrayFields[$fieldName])) { + if(is_array($selector->field) || is_array($selector->value)) { + throw new PageFinderException("OR-condition not supported in '$selector'"); + } } if($fieldName === 'status') { @@ -507,6 +519,7 @@ class PageFinder extends Wire { // for getTotal auto detect $limit = (int) $selector->value; $limitSelector = $selector; + // @todo allow for array value that specifies start and limit, i.e. '10|25' } else if($fieldName == 'start') { // for getTotal auto detect diff --git a/wire/modules/Inputfield/InputfieldSelector/InputfieldSelector.module b/wire/modules/Inputfield/InputfieldSelector/InputfieldSelector.module index d92a881c..e042eb92 100644 --- a/wire/modules/Inputfield/InputfieldSelector/InputfieldSelector.module +++ b/wire/modules/Inputfield/InputfieldSelector/InputfieldSelector.module @@ -397,7 +397,7 @@ class InputfieldSelector extends Inputfield implements ConfigurableModule { 'page' => array('@=', '@!='), 'checkbox' => array('=', '!='), 'sort' => array('.=', '.=-'), - 'status' => array('@=', '@!='), + 'status' => array('@=', '@!=', '<', '<=', '>', '>='), //'selector' => array('#=', '#!='), 'selector' => array('=', '!=', '<', '>', '<=', '>='), ); @@ -523,7 +523,7 @@ class InputfieldSelector extends Inputfield implements ConfigurableModule { 'temp' => $this->_('Temp'), ), 'sanitizer' => 'integer', - 'operators' => array('@=', '@!='), + 'operators' => $this->operatorsByType['status'], ), 'template' => array( 'input' => 'select',