From d76fc7189593e7e79582c528c09157459fe89cce Mon Sep 17 00:00:00 2001 From: Git'Fellow <12234510+solracsf@users.noreply.github.com> Date: Tue, 21 Jul 2026 12:07:34 +0200 Subject: [PATCH] fix(NavigationManager): do not warn when an unknown entry is requested get() is declared to return ?array and all of its callers handle null - the public page layout explicitly renders an empty app list when the current app has no navigation entry. The lookup itself did not guard against a missing key though, so every public page rendered by an app that registers no navigation entry (typical for files integration apps like drawio) logged a PHP warning per page view: Undefined array key "drawio" at lib/private/NavigationManager.php#432 Returning null explicitly keeps the behaviour identical for every caller - the expression already evaluated to null after the warning - and removes the log noise. Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com> --- lib/private/NavigationManager.php | 2 +- tests/lib/NavigationManagerTest.php | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/private/NavigationManager.php b/lib/private/NavigationManager.php index 468e2617d67f0..a20969c765a4b 100644 --- a/lib/private/NavigationManager.php +++ b/lib/private/NavigationManager.php @@ -312,7 +312,7 @@ public function setUnreadCounter(string $id, int $unreadCounter): void { #[Override] public function get(string $id): ?array { $this->resolveAppNavigationEntries(); - return $this->entries[$id]; + return $this->entries[$id] ?? null; } #[Override] diff --git a/tests/lib/NavigationManagerTest.php b/tests/lib/NavigationManagerTest.php index 1b2805f9c0860..154456fe872c9 100644 --- a/tests/lib/NavigationManagerTest.php +++ b/tests/lib/NavigationManagerTest.php @@ -171,6 +171,13 @@ public function testAddClosure(array $entry, array $expectedEntry): void { $this->assertEmpty($this->navigationManager->getAll('all'), 'Expected no navigation entry exists after clear()'); } + public function testGetUnknownEntryReturnsNull(): void { + // Requesting an entry no app has registered must return null without + // emitting an "Undefined array key" warning, e.g. when an app without + // a navigation entry renders a public page + $this->assertNull($this->navigationManager->get('unknown')); + } + public function testAddArrayClearGetAll(): void { $entry = [ 'id' => 'entry id',