Skip to content

Commit

Permalink
Fixed PageObject::getRoute() with pages which have no route
Browse files Browse the repository at this point in the history
  • Loading branch information
mahagr committed Jan 14, 2021
1 parent fdfcaae commit 57c6414
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
## mm/dd/2020

1. [](#new)
* Please read [Grav 1.7 Upgrade Guide](https://learn.getgrav.org/17/advanced/grav-development/grav-17-upgrade-guide) before upgrading!
* Added support for overriding configuration by using environment variables
* Use PHP 7.4 serialization (the old `Serializable` methods are now final and cannot be overridden)
* Enabled `ETag` setting by default for 304 responses
Expand All @@ -24,6 +25,7 @@
* Fixed fatal error in PHP 8 when trying to access root page
* Fixed Array->String conversion error when `languages:translations: false` [admin#1896](https://github.com/getgrav/grav-plugin-admin/issues/1896)
* Fixed `Inflector` methods when translation is missing `GRAV.INFLECTOR_*` translations
* Fixed `PageObject::getRoute()` with pages which have no route

# v1.7.0-rc.20
## 12/15/2020
Expand Down
11 changes: 8 additions & 3 deletions system/src/Grav/Common/Flex/Types/Pages/PageObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,16 @@ public function initialize(): void

/**
* @param string|array $query
* @return Route
* @return Route|null
*/
public function getRoute($query = []): Route
public function getRoute($query = []): ?Route
{
$route = RouteFactory::createFromString($this->route());
$route = $this->route();
if (null === $route) {
return null;
}

$route = RouteFactory::createFromString($route);
if ($lang = $route->getLanguage()) {
$grav = Grav::instance();
if (!$grav['config']->get('system.languages.include_default_lang')) {
Expand Down

0 comments on commit 57c6414

Please sign in to comment.