Skip to content

Commit

Permalink
Fix for find() processing redirects via dispatch() - #781
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Apr 12, 2016
1 parent 90481e8 commit c447088
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions system/src/Grav/Common/Page/Pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,18 +297,20 @@ public function children($path)
*/
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;
Expand All @@ -324,7 +326,7 @@ public function dispatch($url, $all = false)
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());
}

Expand Down

0 comments on commit c447088

Please sign in to comment.