Fixed wrong Pages::dispatch() calls (with redirect) when we really meant to call Pages::find()

This commit is contained in:
Matias Griese
2019-09-13 22:39:46 +03:00
parent fa064301a2
commit 90c2079529
8 changed files with 15 additions and 11 deletions

View File

@@ -14,6 +14,7 @@
* Fixed broken Twig `dump()`
* Fixed `Page::modular()` and `Page::modularTwig()` returning `null` for folders and other non-initialized pages
* Fixed 404 error when you click to non-routable menu item with children: redirect to the first child instead
* Fixed wrong `Pages::dispatch()` calls (with redirect) when we really meant to call `Pages::find()`
# v1.7.0-beta.7
## 08/30/2019

View File

@@ -553,7 +553,7 @@ class Grav extends Container
$path_parts = pathinfo($path);
/** @var PageInterface $page */
$page = $this['pages']->dispatch($path_parts['dirname'], true);
$page = $this['pages']->find($path_parts['dirname'], true);
if ($page) {
$media = $page->media()->all();

View File

@@ -185,7 +185,7 @@ class Excerpts
$page_route = '/' . ltrim(str_replace($base_url, '', $folder), '/');
/** @var PageInterface $ext_page */
$ext_page = $grav['pages']->dispatch($page_route, true);
$ext_page = $grav['pages']->find($page_route, true);
if ($ext_page) {
$media = $ext_page->getMedia();
} else {

View File

@@ -2463,7 +2463,7 @@ class Page implements PageInterface
if (isset($routes[$uri_path])) {
/** @var PageInterface $child_page */
$child_page = $pages->dispatch($uri->route())->parent();
$child_page = $pages->find($uri->route())->parent();
if ($child_page) {
while (!$child_page->root()) {
if ($this->path() === $child_page->path()) {

View File

@@ -736,7 +736,7 @@ class Pages
public function ancestor($route, $path = null)
{
if ($path !== null) {
$page = $this->dispatch($route, true);
$page = $this->find($route, true);
if ($page && $page->path() === $path) {
return $page;
@@ -763,7 +763,7 @@ class Pages
{
if ($field !== null) {
$page = $this->dispatch($route, true);
$page = $this->find($route, true);
$parent = $page ? $page->parent() : null;
if ($parent && $parent->value('header.' . $field) !== null) {

View File

@@ -3,10 +3,12 @@
use Codeception\Util\Fixtures;
use Grav\Common\Helpers\Excerpts;
use Grav\Common\Grav;
use Grav\Common\Page\Interfaces\PageInterface;
use Grav\Common\Uri;
use Grav\Common\Config\Config;
use Grav\Common\Page\Pages;
use Grav\Common\Language\Language;
use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
/**
* Class ExcerptsTest
@@ -64,7 +66,7 @@ class ExcerptsTest extends \Codeception\TestCase\Test
'escape_markup' => false,
'special_chars' => ['>' => 'gt', '<' => 'lt'],
];
$this->page = $this->pages->dispatch('/item2/item2-2');
$this->page = $this->pages->find('/item2/item2-2');
$this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init();
}

View File

@@ -8,6 +8,7 @@ use Grav\Common\Config\Config;
use Grav\Common\Page\Pages;
use Grav\Common\Markdown\Parsedown;
use Grav\Common\Language\Language;
use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
/**
@@ -66,7 +67,7 @@ class ParsedownTest extends \Codeception\TestCase\Test
],
'images' => $this->config->get('system.images', [])
];
$page = $this->pages->dispatch('/item2/item2-2');
$page = $this->pages->find('/item2/item2-2');
$excerpts = new Excerpts($page, $defaults);
$this->parsedown = new Parsedown($excerpts);
@@ -194,7 +195,7 @@ class ParsedownTest extends \Codeception\TestCase\Test
],
'images' => $this->config->get('system.images', [])
];
$page = $this->pages->dispatch('/');
$page = $this->pages->find('/');
$excerpts = new Excerpts($page, $defaults);
$this->parsedown = new Parsedown($excerpts);
@@ -249,7 +250,7 @@ class ParsedownTest extends \Codeception\TestCase\Test
],
'images' => $this->config->get('system.images', [])
];
$page = $this->pages->dispatch('/');
$page = $this->pages->find('/');
$excerpts = new Excerpts($page, $defaults);
$this->parsedown = new Parsedown($excerpts);

View File

@@ -96,7 +96,7 @@ class PagesTest extends \Codeception\TestCase\Test
$locator = $this->grav['locator'];
$folder = $locator->findResource('tests://');
$aPage = $this->pages->dispatch('/blog');
$aPage = $this->pages->find('/blog');
$subPagesSorted = $this->pages->sort($aPage);
$this->assertInternalType('array', $subPagesSorted);
@@ -132,7 +132,7 @@ class PagesTest extends \Codeception\TestCase\Test
$locator = $this->grav['locator'];
$folder = $locator->findResource('tests://');
$aPage = $this->pages->dispatch('/blog');
$aPage = $this->pages->find('/blog');
$subPagesSorted = $this->pages->sortCollection($aPage->children(), $aPage->orderBy());
$this->assertInternalType('array', $subPagesSorted);