From 8f56670a804031c1c7a202ceb3374e2f68eb0d34 Mon Sep 17 00:00:00 2001 From: Kamil Kuzminski Date: Thu, 8 Dec 2022 12:57:40 +0100 Subject: [PATCH] Fix a potential PHP 8 warning if the target page is not found --- .../Navigation/AbstractNavigationListener.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/EventListener/Navigation/AbstractNavigationListener.php b/src/EventListener/Navigation/AbstractNavigationListener.php index 76de16c..bbc1268 100644 --- a/src/EventListener/Navigation/AbstractNavigationListener.php +++ b/src/EventListener/Navigation/AbstractNavigationListener.php @@ -61,12 +61,18 @@ public function onChangelanguageNavigation(ChangelanguageNavigationEvent $event) return; } + $targetPage = $navigationItem->getTargetPage(); + + if (null === $targetPage) { + return; + } + $translated = $this->findPublishedBy( [ "($t.id=? OR $t.languageMain=?)", sprintf('%s.pid=(SELECT id FROM %s WHERE (id=? OR master=?) AND jumpTo=?)', $t, $parent::getTable()), ], - [$mainId, $mainId, $masterId, $masterId, $navigationItem->getTargetPage()->id] + [$mainId, $mainId, $masterId, $masterId, $targetPage->id] ); if (null === $translated) {