From 1363ea4370b8f92fc3b6e79abb4cafd71949dc0f Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 10 Aug 2015 14:02:19 +0200 Subject: [PATCH] Menu: Defer construction of the Url object to Menu::getUrl() Before, the Url object was constructed in Menu::setUrl() which lead to an exception when parsing a module's configuration.php from our CLI. refs #9375 --- library/Icinga/Web/Menu.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/library/Icinga/Web/Menu.php b/library/Icinga/Web/Menu.php index 3ad8d347f..7992364b9 100644 --- a/library/Icinga/Web/Menu.php +++ b/library/Icinga/Web/Menu.php @@ -43,7 +43,7 @@ class Menu implements RecursiveIterator /** * The url of this menu * - * @var string + * @var string|null */ protected $url; @@ -404,21 +404,20 @@ class Menu implements RecursiveIterator */ public function setUrl($url) { - if ($url instanceof Url) { - $this->url = $url; - } else { - $this->url = Url::fromPath($url); - } + $this->url = $url; return $this; } /** * Return the url of this menu * - * @return Url + * @return Url|null */ public function getUrl() { + if ($this->url !== null && ! $this->url instanceof Url) { + $this->url = Url::fromPath($this->url); + } return $this->url; }