From 64284f46930b812cf3b74557fb9256f01ecaef79 Mon Sep 17 00:00:00 2001 From: jdlrobson Date: Wed, 30 Dec 2020 16:38:36 -0800 Subject: [PATCH] `id` may not be defined so check e.g. ``` $wgHooks['SidebarBeforeOutput'][] = function ( $skin, &$bar ) { # note: heading can be either a message key. If no message exists it will be treated as a plain text. $bar[ 'sunday' ] = [ [ 'label' => 'msg-myid', 'msg' => 'my-label-message', 'href' => '//example.com' ] ]; }; ``` Fixes: #212 --- src/Components/NavMenu.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Components/NavMenu.php b/src/Components/NavMenu.php index e384ccc3..b961adbb 100644 --- a/src/Components/NavMenu.php +++ b/src/Components/NavMenu.php @@ -114,8 +114,9 @@ protected function buildMenuItemsForDropdownMenu( $menuDescription, $indent = 0 $this->indent( $indent ); foreach ( $menuDescription['content'] as $key => $item ) { + $id = $item['id'] ?? ''; $menuitems .= $this->indent() . $this->getSkinTemplate()->makeListItem( $key, $item, - [ 'tag' => 'div', 'class' => 'nav-item', 'link-class' => 'nav-link '.$item['id'] ] ); + [ 'tag' => 'div', 'class' => 'nav-item', 'link-class' => 'nav-link '. $id ] ); } $this->indent( - $indent );