From 47086751d282a82ead9b971bf34c186f1ecf9c30 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Fri, 5 May 2023 13:00:14 -0400 Subject: [PATCH] Bump version to 3.0.217 --- wire/core/NullPage.php | 47 +++++++++++++++++++++++-------------- wire/core/PageAccess.php | 14 +++++++---- wire/core/Pagefile.php | 1 - wire/core/PagesAccess.php | 9 ++++--- wire/core/ProcessWire.php | 2 +- wire/core/WireTextTools.php | 9 ++++--- 6 files changed, 49 insertions(+), 33 deletions(-) diff --git a/wire/core/NullPage.php b/wire/core/NullPage.php index 6080a85b..2ad7af44 100644 --- a/wire/core/NullPage.php +++ b/wire/core/NullPage.php @@ -25,7 +25,7 @@ * Placeholder class for non-existant and non-saveable Page. * Many API functions return a NullPage to indicate no match. * - * ProcessWire 3.x, Copyright 2016 by Ryan Cramer + * ProcessWire 3.x, Copyright 2023 by Ryan Cramer * https://processwire.com * * @property int $id The id property will always be 0 for a NullPage. @@ -77,7 +77,9 @@ class NullPage extends Page implements WireNull { * @throws WireException * */ - public function parents($selector = '') { return $this->wire('pages')->newPageArray(); } + public function parents($selector = '') { + return $this->wire()->pages->newPageArray(); + } /** * #pw-internal @@ -110,7 +112,22 @@ class NullPage extends Page implements WireNull { * @throws WireException * */ - public function ___rootParent() { return $this->wire('pages')->newNullPage(); } + public function ___rootParent() { + return $this->wire()->pages->newNullPage(); + } + + /** + * #pw-internal + * + * @param string $selector + * @param bool $includeCurrent + * @return PageArray + * @throws WireException + * + */ + public function siblings($selector = '', $includeCurrent = true) { + return $this->wire()->pages->newPageArray(); + } /** * #pw-internal @@ -121,18 +138,9 @@ class NullPage extends Page implements WireNull { * @throws WireException * */ - public function siblings($selector = '', $options = array()) { return $this->wire('pages')->newPageArray(); } - - /** - * #pw-internal - * - * @param string $selector - * @param array $options - * @return PageArray - * @throws WireException - * - */ - public function children($selector = '', $options = array()) { return $this->wire('pages')->newPageArray(); } + public function children($selector = '', $options = array()) { + return $this->wire()->pages->newPageArray(); + } /** * #pw-internal @@ -142,7 +150,9 @@ class NullPage extends Page implements WireNull { * @throws WireException * */ - public function getAccessParent($type = 'view') { return $this->wire('pages')->newNullPage(); } + public function getAccessParent($type = 'view') { + return $this->wire()->pages->newNullPage(); + } /** * #pw-internal @@ -152,7 +162,9 @@ class NullPage extends Page implements WireNull { * @throws WireException * */ - public function getAccessRoles($type = 'view') { return $this->wire('pages')->newPageArray(); } + public function getAccessRoles($type = 'view') { + return $this->wire()->pages->newPageArray(); + } /** * #pw-internal @@ -173,4 +185,3 @@ class NullPage extends Page implements WireNull { */ public function isChanged($what = '') { return false; } } - diff --git a/wire/core/PageAccess.php b/wire/core/PageAccess.php index a776b2d3..71a143f7 100644 --- a/wire/core/PageAccess.php +++ b/wire/core/PageAccess.php @@ -5,7 +5,7 @@ * * Provides implementation for Page access functions. * - * ProcessWire 3.x, Copyright 2016 by Ryan Cramer + * ProcessWire 3.x, Copyright 2023 by Ryan Cramer * https://processwire.com * */ @@ -85,7 +85,7 @@ class PageAccess { $parent = null; - if($type === 'edit' && $page->isTrash() && $page->id != $page->wire('config')->trashPageID) { + if($type === 'edit' && $page->isTrash() && $page->id != $page->wire()->config->trashPageID) { // pages in trash have an edit access parent as whatever it was prior to being trashed $info = $pages->trasher()->parseTrashPageName($page->name); if(!empty($info['parent_id'])) $parent = $pages->get((int) $info['parent_id']); @@ -160,9 +160,13 @@ class PageAccess { * */ public function wire($name = '', $value = null, $lock = false) { - if(!is_null($value)) return $this->wire->wire($name, $value, $lock); - else if($name instanceof WireFuelable && $this->wire) $name->setWire($this->wire); - else if($name) return $this->wire->wire($name); + if(!is_null($value)) { + return $this->wire->wire($name, $value, $lock); + } else if($name instanceof WireFuelable && $this->wire) { + $name->setWire($this->wire); + } else if($name) { + return $this->wire->wire($name); + } return $this->wire; } diff --git a/wire/core/Pagefile.php b/wire/core/Pagefile.php index b1a7bf04..49267e65 100644 --- a/wire/core/Pagefile.php +++ b/wire/core/Pagefile.php @@ -1511,4 +1511,3 @@ class Pagefile extends WireData implements WireArrayItem { return $info; } } - diff --git a/wire/core/PagesAccess.php b/wire/core/PagesAccess.php index 40e3def0..c40f8fbb 100644 --- a/wire/core/PagesAccess.php +++ b/wire/core/PagesAccess.php @@ -17,7 +17,7 @@ * Pages using templates that already define their access (determined by $template->useRoles) * are omitted from the pages_access table, as they aren't necessary. * - * ProcessWire 3.x, Copyright 2022 by Ryan Cramer + * ProcessWire 3.x, Copyright 2023 by Ryan Cramer * https://processwire.com * * @@ -194,8 +194,6 @@ class PagesAccess extends Wire { if(!$accessParent->id || $accessParent->id == $page->id) { // page is the same as the one that defines access, so it doesn't need to be here $query = $database->prepare("DELETE FROM pages_access WHERE pages_id=:page_id"); - $query->bindValue(":page_id", $page_id, \PDO::PARAM_INT); - $query->execute(); } else { $template_id = (int) $accessParent->template->id; @@ -205,11 +203,12 @@ class PagesAccess extends Wire { "ON DUPLICATE KEY UPDATE templates_id=VALUES(templates_id) "; $query = $database->prepare($sql); - $query->bindValue(":page_id", $page_id, \PDO::PARAM_INT); $query->bindValue(":template_id", $template_id, \PDO::PARAM_INT); - $query->execute(); } + $query->bindValue(":page_id", $page_id, \PDO::PARAM_INT); + $query->execute(); + if($page->numChildren > 0) { if($page->parentPrevious && $accessParent->id != $page->id) { diff --git a/wire/core/ProcessWire.php b/wire/core/ProcessWire.php index 9a669645..9e02ff4a 100644 --- a/wire/core/ProcessWire.php +++ b/wire/core/ProcessWire.php @@ -79,7 +79,7 @@ class ProcessWire extends Wire { * Reversion revision number * */ - const versionRevision = 216; + const versionRevision = 217; /** * Version suffix string (when applicable) diff --git a/wire/core/WireTextTools.php b/wire/core/WireTextTools.php index 0e91c524..e5d653de 100644 --- a/wire/core/WireTextTools.php +++ b/wire/core/WireTextTools.php @@ -85,6 +85,9 @@ class WireTextTools extends Wire { ), 'finishReplacements' => array(), // replacements applied at very end (internal) ); + + $str = (string) $str; + if(!strlen($str)) return ''; // merge options using arrays foreach(array('replacements') as $key) { @@ -379,7 +382,7 @@ class WireTextTools extends Wire { * - `linksToUrls` (bool): Convert links to "(url)" rather than removing entirely? (default=false) Since 3.0.132 * - `endBlocksWith` (string): Character or string to insert to identify paragraph/header separation (default='') * - `convertEntities` (bool): Convert entity-encoded characters to text? (default=true) - * @return mixed|string + * @return string * */ public function collapse($str, array $options = array()) { @@ -762,7 +765,7 @@ class WireTextTools extends Wire { * Get array of punctuation characters * * @param bool $sentence Get only sentence-ending punctuation - * @return array|string + * @return array * */ public function getPunctuationChars($sentence = false) { @@ -1334,7 +1337,7 @@ class WireTextTools extends Wire { $str = array_shift($parts); - foreach($parts as $key => $part) { + foreach($parts as $part) { $len = $this->strlen($part); $char = $len > 0 ? $this->substr($part, 0, 1) : ''; // char being escaped