Skip to content

Commit d76fc71

Browse files
committed
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>
1 parent e8afe36 commit d76fc71

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

lib/private/NavigationManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ public function setUnreadCounter(string $id, int $unreadCounter): void {
312312
#[Override]
313313
public function get(string $id): ?array {
314314
$this->resolveAppNavigationEntries();
315-
return $this->entries[$id];
315+
return $this->entries[$id] ?? null;
316316
}
317317

318318
#[Override]

tests/lib/NavigationManagerTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,13 @@ public function testAddClosure(array $entry, array $expectedEntry): void {
171171
$this->assertEmpty($this->navigationManager->getAll('all'), 'Expected no navigation entry exists after clear()');
172172
}
173173

174+
public function testGetUnknownEntryReturnsNull(): void {
175+
// Requesting an entry no app has registered must return null without
176+
// emitting an "Undefined array key" warning, e.g. when an app without
177+
// a navigation entry renders a public page
178+
$this->assertNull($this->navigationManager->get('unknown'));
179+
}
180+
174181
public function testAddArrayClearGetAll(): void {
175182
$entry = [
176183
'id' => 'entry id',

0 commit comments

Comments
 (0)