From 37f95199f4b9c3ab5b0c4902f707fd8d24cc9847 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Mon, 26 Feb 2018 06:27:29 -0500 Subject: [PATCH] Add descriptive error message when trying to use OR values with path/URL and core PathPaths module is not installed, per processwire/processwire-issues#504 --- wire/core/PageFinder.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/wire/core/PageFinder.php b/wire/core/PageFinder.php index ce44dd60..aec0f1e8 100644 --- a/wire/core/PageFinder.php +++ b/wire/core/PageFinder.php @@ -1848,6 +1848,7 @@ class PageFinder extends Wire { foreach($this->wire('languages') as $language) { if(!$language->isDefault()) $langNames[$language->id] = "name" . (int) $language->id; } + if(!count($langNames)) $langNames = null; } else { $langNames = null; } @@ -1869,6 +1870,14 @@ class PageFinder extends Wire { $query->where("pages.id=1"); } else { $selectorValue = $selector->value; + if(is_array($selectorValue)) { + // only the PagePaths module can perform OR value searches on path/url + if($langNames) { + throw new PageFinderSyntaxException("OR values not supported for multi-language 'path' or 'url'"); + } else { + throw new PageFinderSyntaxException("OR value support of 'path' or 'url' requires core PagePaths module"); + } + } if($langNames) $selectorValue = $this->wire('modules')->get('LanguageSupportPageNames')->updatePath($selectorValue); $parts = explode('/', rtrim($selectorValue, '/')); $part = $database->escapeStr($this->wire('sanitizer')->pageName(array_pop($parts), Sanitizer::toAscii));