diff --git a/wire/core/Fuel.php b/wire/core/Fuel.php index 4e7a2404..247e4fa4 100644 --- a/wire/core/Fuel.php +++ b/wire/core/Fuel.php @@ -10,7 +10,7 @@ * This file is licensed under the MIT license * https://processwire.com/about/license/mit/ * - * ProcessWire 3.x, Copyright 2016 by Ryan Cramer + * ProcessWire 3.x, Copyright 2019 by Ryan Cramer * https://processwire.com * * @property ProcessWire $wire @@ -37,6 +37,9 @@ * @property Config $config * @property Fuel $fuel * @property WireProfilerInterface $profiler + * @property WireFileTools $files + * @property WireMailTools $mail + * @property WireDateTime $datetime * */ class Fuel implements \IteratorAggregate { @@ -66,6 +69,17 @@ class Fuel implements \IteratorAggregate { protected $requiredInterfaces = array( 'profiler' => 'WireProfilerInterface' ); + + /** + * The most common API variable names, those likely to be called multiple times in any request + * + * @var array + * + */ + static protected $commonNames = array( + 'page' => 1, 'pages' => 1, 'session' => 1, 'input' => 1, 'sanitizer' => 1, 'config' => 1, + 'user' => 1, 'users' => 1, 'fields' => 1, 'templates' => 1, 'database' => 1, 'modules' => 1, + ); /** * @param string $key API variable name to set - should be valid PHP variable name. @@ -110,6 +124,10 @@ class Fuel implements \IteratorAggregate { public function __get($key) { return isset($this->data[$key]) ? $this->data[$key] : null; } + + public function get($key) { + return isset($this->data[$key]) ? $this->data[$key] : null; + } public function getIterator() { return new \ArrayObject($this->data); @@ -119,4 +137,7 @@ class Fuel implements \IteratorAggregate { return $this->data; } + public static function isCommon($name) { + return isset(self::$commonNames[$name]); + } } diff --git a/wire/core/PageFinder.php b/wire/core/PageFinder.php index f391644f..c1fe1738 100644 --- a/wire/core/PageFinder.php +++ b/wire/core/PageFinder.php @@ -767,6 +767,19 @@ class PageFinder extends Wire { // allow any Fieldtype that is an instance of given one, or extends it if(!wireInstanceOf($f->type, $fieldtype) && ($fieldtypeLang === null || !wireInstanceOf($f->type, $fieldtypeLang))) continue; + /** potential replacement for the above 2 lines + if($f->type->className() === $fieldName) { + // always allowed + } else if(!wireInstanceOf($f->type, $fieldtype) && ($fieldtypeLang === null || !wireInstanceOf($f->type, $fieldtypeLang))) { + // this field’s type does not extend the one we are looking for + continue; + } else { + // looks good, but now check operators + $selectorInfo = $f->type->getSelectorInfo($f); + // if operator used in selector is not an allowed one, then skip over this field + if(!in_array($selector->operator(), $selectorInfo['operators'])) continue; + } + */ } else { // only allow given Fieldtype @@ -1979,11 +1992,11 @@ class PageFinder extends Wire { throw new PageFinderSyntaxException("Operator '$selector->operator' is not supported for path or url unless: 1) non-multi-language; 2) you install the PagePaths module."); } - if($selector->value == '/') { + $selectorValue = $selector->value; + if($selectorValue === '/') { $parts = array(); $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) { @@ -1997,7 +2010,7 @@ class PageFinder extends Wire { $part = $database->escapeStr($this->wire('sanitizer')->pageName(array_pop($parts), Sanitizer::toAscii)); $sql = "pages.name='$part'"; if($langNames) foreach($langNames as $name) $sql .= " OR pages.$name='$part'"; - $query->where($sql); + $query->where("($sql)"); if(!count($parts)) $query->where("pages.parent_id=1"); } diff --git a/wire/core/ProcessWire.php b/wire/core/ProcessWire.php index 8310c7e6..295aa3e4 100644 --- a/wire/core/ProcessWire.php +++ b/wire/core/ProcessWire.php @@ -20,6 +20,8 @@ require_once(__DIR__ . '/boot.php'); * ProcessWire 3.x, Copyright 2019 by Ryan Cramer * https://processwire.com * + * @property Fuel $fuel + * * @method init() * @method ready() * @method finished() @@ -734,8 +736,9 @@ class ProcessWire extends Wire { } public function __get($key) { - if($key == 'shutdown') return $this->shutdown; - if($key == 'instanceID') return $this->instanceID; + if($key === 'fuel') return $this->fuel; + if($key === 'shutdown') return $this->shutdown; + if($key === 'instanceID') return $this->instanceID; return parent::__get($key); } diff --git a/wire/core/WireTextTools.php b/wire/core/WireTextTools.php index 27372bad..df7c286a 100644 --- a/wire/core/WireTextTools.php +++ b/wire/core/WireTextTools.php @@ -502,6 +502,7 @@ class WireTextTools extends Wire { $tests = array(); $punctuationChars = $this->getPunctuationChars(); $endSentenceChars = $this->getPunctuationChars(true); + $endSentenceChars[] = ':'; if($options['keepFormatTags']) { $options['keepTags'] = array_merge($options['keepTags'], array(