From 16fb7127701ac5149faabb59592c48975ab7e323 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Fri, 22 May 2020 20:06:40 +0300 Subject: [PATCH] Do not use `$pages->dispatch()` to find a page, it redirects! --- CHANGELOG.md | 6 ++++++ classes/plugin/Admin.php | 12 ++++++------ classes/plugin/AdminController.php | 4 ++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57bb16ab..c9252f94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v1.10.0-rc.12 +## mm/dd/2020 + +1. [](#bugfix) + * Use `Pages::find()` instead of `Pages::dispatch()` as we do not want to redirect out of admin + # v1.10.0-rc.11 ## 05/14/2020 diff --git a/classes/plugin/Admin.php b/classes/plugin/Admin.php index 21fc1401..fa36caeb 100644 --- a/classes/plugin/Admin.php +++ b/classes/plugin/Admin.php @@ -391,7 +391,7 @@ class Admin $route = '/' . ltrim($this->route, '/'); /** @var PageInterface $page */ - $page = $pages->dispatch($route); + $page = $pages->find($route); $parent_route = null; if ($page) { /** @var PageInterface $parent */ @@ -490,7 +490,7 @@ class Admin $route = '/' . ltrim($grav['admin']->route, '/'); /** @var PageInterface $page */ - $page = $pages->dispatch($route); + $page = $pages->find($route); $parent_route = null; if ($page) { $media = $page->media()->all(); @@ -1250,7 +1250,7 @@ class Admin } foreach ($pages->routes() as $url => $path) { - $page = $pages->dispatch($url, true); + $page = $pages->find($url, true); if ($page && $page->routable()) { $latest[$page->route()] = ['modified' => $page->modified(), 'page' => $page]; } @@ -1817,7 +1817,7 @@ class Admin // Fix for entities in path causing looping... $path = urldecode($path); - $page = $path ? $pages->dispatch($path, true) : $pages->root(); + $page = $path ? $pages->find($path, true) : $pages->root(); if (!$page) { $slug = basename($path); @@ -1970,7 +1970,7 @@ class Admin $pages = static::enablePages(); if ($param_page) { - $page = $pages->dispatch($param_page); + $page = $pages->find($param_page); $page_files = $this->getFiles('images', $page, $page_files, $filtered); $page_files = $this->getFiles('videos', $page, $page_files, $filtered); @@ -2204,7 +2204,7 @@ class Admin $pages->enablePages(); // If page is null, the default page does not exist, and we cannot route to it - $page = $pages->dispatch('/', true); + $page = $pages->find('/', true); if ($page) { // Set original route for the home page. $home = '/' . trim($grav['config']->get('system.home.alias'), '/'); diff --git a/classes/plugin/AdminController.php b/classes/plugin/AdminController.php index 9a6e25d2..85cd1722 100644 --- a/classes/plugin/AdminController.php +++ b/classes/plugin/AdminController.php @@ -1320,7 +1320,7 @@ class AdminController extends AdminBaseController } } - $parent = $route && $route !== '/' && $route !== '.' && $route !== '/.' ? $pages->dispatch($route, true) : $pages->root(); + $parent = $route && $route !== '/' && $route !== '.' && $route !== '/.' ? $pages->find($route, true) : $pages->root(); $original_order = (int)trim($obj->order(), '.'); try { @@ -1747,7 +1747,7 @@ class AdminController extends AdminBaseController $pages = $this->admin::enablePages(); /** @var PageInterface $page */ - $page = $pages->dispatch($rawroute); + $page = $pages->find($rawroute); if ($page) { $child_type = $page->childType();