Fix for find() processing redirects via dispatch() - #781

This commit is contained in:
Andy Miller
2016-04-12 16:25:16 -06:00
parent 90481e8a6d
commit c4470889b4
2 changed files with 7 additions and 4 deletions

View File

@@ -40,6 +40,7 @@
* Fix for a remote link breaking all CSS rewrites for pipeline
* Fix an issue with Retina alternatives not clearing properly between repeat uses
* Fix for non standard http/s external markdown links - [#738](https://github.com/getgrav/grav/issues/738)
* Fix for `find()` calling redirects via `dispatch()` causing infinite loops - [#781](https://github.com/getgrav/grav/issues/781)
# v1.0.10
## 02/11/2016

View File

@@ -297,18 +297,20 @@ class Pages
*/
public function find($url, $all = false)
{
return $this->dispatch($url, $all);
return $this->dispatch($url, $all, false);
}
/**
* Dispatch URI to a page.
*
* @param string $url The relative URL of the page
* @param bool $all
* @param bool $all
*
* @param bool $redirect
* @return Page|null
* @throws \Exception
*/
public function dispatch($url, $all = false)
public function dispatch($url, $all = false, $redirect = true)
{
// Fetch page if there's a defined route to it.
$page = isset($this->routes[$url]) ? $this->get($this->routes[$url]) : null;
@@ -324,7 +326,7 @@ class Pages
if (!$all && $not_admin && (!$page || ($page && !$page->routable()) || ($page && $page->redirect()))) {
// If the page is a simple redirect, just do it.
if ($page && $page->redirect()) {
if ($redirect && $page && $page->redirect()) {
$this->grav->redirectLangSafe($page->redirect());
}