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

@@ -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'), '/');