From 9aa0de63518ae287dab542b35028d155d2532e24 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Fri, 30 Nov 2018 13:15:27 -0500 Subject: [PATCH] Fix issue processwire/processwire-issues#743 --- wire/core/Selectors.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/wire/core/Selectors.php b/wire/core/Selectors.php index dea62422..b71d7c49 100644 --- a/wire/core/Selectors.php +++ b/wire/core/Selectors.php @@ -104,6 +104,7 @@ class Selectors extends WireArray { * */ public function __construct($selector = null) { + parent::__construct(); if(!is_null($selector)) $this->init($selector); } @@ -228,7 +229,7 @@ class Selectors extends WireArray { if(!isset(self::$selectorTypes[$operator])) return false; $type = self::$selectorTypes[$operator]; // now double check that we can map it back, in case PHP filters anything in the isset() - $op = array_search($type); + $op = array_search($type, self::$selectorTypes); if($op === $operator) { if($is) return true; // Convert types like "SelectorEquals" to "Equals" @@ -399,7 +400,7 @@ class Selectors extends WireArray { * * @param string $field Field name or names (separated by a pipe) * @param string $operator Operator, i.e. "=" - * @param string $value Value or values (separated by a pipe) + * @param string|array $value Value or values (separated by a pipe) * @return Selector Returns the correct type of `Selector` object that corresponds to the given `$operator`. * @throws WireException * @@ -1150,7 +1151,7 @@ class Selectors extends WireArray { $_sanitize = $sanitize; if(is_array($value)) $value = 'array'; // we don't allow arrays here if(is_object($value)) $value = (string) $value; - if(is_int($value) || ctype_digit($value)) { + if(is_int($value) || (ctype_digit("$value") && strpos($value, '0') !== 0)) { $value = (int) $value; if($_sanitize == 'selectorValue') $_sanitize = ''; // no need to sanitize integer to string }