diff --git a/wire/core/Pages.php b/wire/core/Pages.php index 4d119533..12f1b052 100644 --- a/wire/core/Pages.php +++ b/wire/core/Pages.php @@ -1004,7 +1004,7 @@ class Pages extends Wire { * * #pw-internal * - * @param Page|PageArray|null $page Page to uncache, or omit to uncache all. + * @param Page|PageArray|int|null $page Page to uncache, PageArray of pages to uncache, ID of page to uncache (3.0.153+), or omit to uncache all. * @param array $options Additional options to modify behavior: * - `shallow` (bool): By default, this method also calls $page->uncache(). To prevent that call, set this to true. * @return int Number of pages uncached @@ -1014,7 +1014,7 @@ class Pages extends Wire { $cnt = 0; if(is_null($page)) { $cnt = $this->cacher->uncacheAll(null, $options); - } else if($page instanceof Page) { + } else if($page instanceof Page || is_int($page)) { if($this->cacher->uncache($page, $options)) $cnt++; } else if($page instanceof PageArray) { foreach($page as $p) { diff --git a/wire/core/PagesLoaderCache.php b/wire/core/PagesLoaderCache.php index b1449bf7..b08f4de0 100644 --- a/wire/core/PagesLoaderCache.php +++ b/wire/core/PagesLoaderCache.php @@ -78,16 +78,24 @@ class PagesLoaderCache extends Wire { * * Note: does not remove pages from selectorCache. Call uncacheAll to do that. * - * @param Page $page Page to uncache + * @param Page|int $page Page to uncache or ID of page (prior to 3.0.153 only Page object was accepted) * @param array $options Additional options to modify behavior: * - `shallow` (bool): By default, this method also calls $page->uncache(). To prevent call to $page->uncache(), set 'shallow' => true. * @return bool True if page was uncached, false if it didn't need to be * */ - public function uncache(Page $page, array $options = array()) { - if(empty($options['shallow'])) $page->uncache(); - if(isset($this->pageIdCache[$page->id])) { - unset($this->pageIdCache[$page->id]); + public function uncache($page, array $options = array()) { + if($page instanceof Page) { + $pageId = $page->id; + } else { + $pageId = is_int($page) ? $page : (int) "$page"; + $page = isset($this->pageIdCache[$pageId]) ? $this->pageIdCache[$pageId] : null; + } + if(empty($options['shallow']) && $page) { + $page->uncache(); + } + if(isset($this->pageIdCache[$pageId])) { + unset($this->pageIdCache[$pageId]); return true; } else { return false;