Do not use $pages->dispatch() to find a page, it redirects!

This commit is contained in:
Matias Griese
2020-05-22 20:06:40 +03:00
parent 0cfc7e031c
commit 16fb712770
3 changed files with 14 additions and 8 deletions

View File

@@ -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 # v1.10.0-rc.11
## 05/14/2020 ## 05/14/2020

View File

@@ -391,7 +391,7 @@ class Admin
$route = '/' . ltrim($this->route, '/'); $route = '/' . ltrim($this->route, '/');
/** @var PageInterface $page */ /** @var PageInterface $page */
$page = $pages->dispatch($route); $page = $pages->find($route);
$parent_route = null; $parent_route = null;
if ($page) { if ($page) {
/** @var PageInterface $parent */ /** @var PageInterface $parent */
@@ -490,7 +490,7 @@ class Admin
$route = '/' . ltrim($grav['admin']->route, '/'); $route = '/' . ltrim($grav['admin']->route, '/');
/** @var PageInterface $page */ /** @var PageInterface $page */
$page = $pages->dispatch($route); $page = $pages->find($route);
$parent_route = null; $parent_route = null;
if ($page) { if ($page) {
$media = $page->media()->all(); $media = $page->media()->all();
@@ -1250,7 +1250,7 @@ class Admin
} }
foreach ($pages->routes() as $url => $path) { foreach ($pages->routes() as $url => $path) {
$page = $pages->dispatch($url, true); $page = $pages->find($url, true);
if ($page && $page->routable()) { if ($page && $page->routable()) {
$latest[$page->route()] = ['modified' => $page->modified(), 'page' => $page]; $latest[$page->route()] = ['modified' => $page->modified(), 'page' => $page];
} }
@@ -1817,7 +1817,7 @@ class Admin
// Fix for entities in path causing looping... // Fix for entities in path causing looping...
$path = urldecode($path); $path = urldecode($path);
$page = $path ? $pages->dispatch($path, true) : $pages->root(); $page = $path ? $pages->find($path, true) : $pages->root();
if (!$page) { if (!$page) {
$slug = basename($path); $slug = basename($path);
@@ -1970,7 +1970,7 @@ class Admin
$pages = static::enablePages(); $pages = static::enablePages();
if ($param_page) { 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('images', $page, $page_files, $filtered);
$page_files = $this->getFiles('videos', $page, $page_files, $filtered); $page_files = $this->getFiles('videos', $page, $page_files, $filtered);
@@ -2204,7 +2204,7 @@ class Admin
$pages->enablePages(); $pages->enablePages();
// If page is null, the default page does not exist, and we cannot route to it // 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) { if ($page) {
// Set original route for the home page. // Set original route for the home page.
$home = '/' . trim($grav['config']->get('system.home.alias'), '/'); $home = '/' . trim($grav['config']->get('system.home.alias'), '/');

View File

@@ -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(), '.'); $original_order = (int)trim($obj->order(), '.');
try { try {
@@ -1747,7 +1747,7 @@ class AdminController extends AdminBaseController
$pages = $this->admin::enablePages(); $pages = $this->admin::enablePages();
/** @var PageInterface $page */ /** @var PageInterface $page */
$page = $pages->dispatch($rawroute); $page = $pages->find($rawroute);
if ($page) { if ($page) {
$child_type = $page->childType(); $child_type = $page->childType();