diff --git a/wire/core/Fieldtypes.php b/wire/core/Fieldtypes.php index e7250e53..f019004b 100644 --- a/wire/core/Fieldtypes.php +++ b/wire/core/Fieldtypes.php @@ -4,6 +4,7 @@ * ProcessWire Fieldtypes * * #pw-summary Maintains a collection of Fieldtype modules. + * #pw-var $fieldtypes * * ProcessWire 3.x, Copyright 2020 by Ryan Cramer * https://processwire.com diff --git a/wire/core/Session.php b/wire/core/Session.php index 5291f012..f01638c1 100644 --- a/wire/core/Session.php +++ b/wire/core/Session.php @@ -1477,18 +1477,25 @@ class Session extends Wire implements \IteratorAggregate { // prevent multiple calls, just in case $this->skipMaintenance = true; - - $historyCnt = (int) $this->config->sessionHistory; + + $config = $this->wire()->config; + $historyCnt = (int) ($config ? $config->sessionHistory : 0); if($historyCnt) { + + $sanitizer = $this->wire()->sanitizer; + $input = $this->wire()->input; + $page = $this->wire()->page; + + if(!$sanitizer || !$input || !$page) return; $history = $this->get('_user', 'history'); if(!is_array($history)) $history = array(); $item = array( 'time' => time(), - 'url' => $this->wire('sanitizer')->entities($this->wire('input')->httpUrl()), - 'page' => $this->wire('page')->id, + 'url' => $sanitizer->entities($input->httpUrl()), + 'page' => $page->id, ); $cnt = count($history); diff --git a/wire/core/WireCache.php b/wire/core/WireCache.php index 8e7edf0c..531e24e4 100644 --- a/wire/core/WireCache.php +++ b/wire/core/WireCache.php @@ -716,15 +716,22 @@ class WireCache extends Wire { public function maintenance($obj = null) { static $done = false; + $forceRun = false; + $database = $this->wire()->database; + $config = $this->wire()->config; + + if(!$database || !$config) return false; if(is_object($obj)) { // check to see if it is worthwhile to perform this kind of maintenance at all if(is_null($this->usePageTemplateMaintenance)) { + $templates = $this->wire()->templates; + if(!$templates) $templates = array(); $minID = 999999; $maxID = 0; - foreach($this->wire('templates') as $template) { + foreach($templates as $template) { if($template->id > $maxID) $maxID = $template->id; if($template->id < $minID) $minID = $template->id; } @@ -733,7 +740,7 @@ class WireCache extends Wire { "WHERE (expires=:expireSave OR expires=:expireSelector) " . "OR (expires>=:minID AND expires<=:maxID)"; - $query = $this->wire('database')->prepare($sql); + $query = $database->prepare($sql); $query->bindValue(':expireSave', self::expireSave); $query->bindValue(':expireSelector', self::expireSelector); $query->bindValue(':minID', date(self::dateFormat, $minID)); @@ -764,7 +771,7 @@ class WireCache extends Wire { } // don't perform general maintenance during ajax requests - if($this->wire('config')->ajax && !$forceRun) return false; + if($config->ajax && !$forceRun) return false; // perform general maintenance now return $this->maintenanceGeneral(); @@ -777,10 +784,11 @@ class WireCache extends Wire { * */ protected function maintenanceGeneral() { + + $database = $this->wire()->database; $sql = 'DELETE FROM caches WHERE (expires<=:now AND expires>:never) '; - - $query = $this->wire('database')->prepare($sql, "cache.maintenance()"); + $query = $database->prepare($sql, "cache.maintenance()"); $query->bindValue(':now', date(self::dateFormat, time())); $query->bindValue(':never', self::expireNever); @@ -808,11 +816,13 @@ class WireCache extends Wire { */ protected function maintenancePage(Page $page) { + $database = $this->wire()->database; + if(is_null($this->cacheNameSelectors)) { // locate all caches that specify selector strings and cache them so that // we don't have to re-load them on every page save try { - $query = $this->wire('database')->prepare("SELECT * FROM caches WHERE expires=:expire"); + $query = $database->prepare("SELECT * FROM caches WHERE expires=:expire"); $query->bindValue(':expire', self::expireSelector); $query->execute(); $this->cacheNameSelectors = array(); @@ -853,7 +863,7 @@ class WireCache extends Wire { $sql .= "OR name=:$key "; } - $query = $this->wire('database')->prepare("DELETE FROM caches WHERE $sql"); + $query = $database->prepare("DELETE FROM caches WHERE $sql"); // bind values $query->bindValue(':expireSave', self::expireSave); @@ -880,7 +890,7 @@ class WireCache extends Wire { protected function maintenanceTemplate(Template $template) { $sql = 'DELETE FROM caches WHERE expires=:expireTemplateID OR expires=:expireSave'; - $query = $this->wire('database')->prepare($sql); + $query = $this->wire()->database->prepare($sql); $query->bindValue(':expireSave', self::expireSave); $query->bindValue(':expireTemplateID', date(self::dateFormat, $template->id)); diff --git a/wire/modules/Process/ProcessPageLister/ProcessPageLister.module b/wire/modules/Process/ProcessPageLister/ProcessPageLister.module index 73a7c55d..a194ca4b 100644 --- a/wire/modules/Process/ProcessPageLister/ProcessPageLister.module +++ b/wire/modules/Process/ProcessPageLister/ProcessPageLister.module @@ -364,7 +364,7 @@ class ProcessPageLister extends Process implements ConfigurableModule { $selector .= ", $s->value"; } $template = $this->getSelectorTemplates($selector); - if(count($template)) $this->set('template', reset($template)); + if(count($template) === 1) $this->set('template', reset($template)); } if($input->post('reset_total')) {