Don't run Vector hook when menu absent from page

While editing I was seeing a fatal due to this error being null
Err on side of caution and check for existence of menu
Follow up to I8309492881142d47eec4da5cc4aa5c6febbd1b35

Bug: T289619
Bug: T299352
Change-Id: I62562969a00eb96c83af4519e0e34e4a77ed8b19
This commit is contained in:
Jon Robson 2022-01-14 08:28:39 -08:00 committed by Jdlrobson
parent 863cdc34bf
commit 55bcce3cc0
1 changed files with 2 additions and 1 deletions

View File

@ -217,7 +217,8 @@ class Hooks {
*/
private static function updateUserLinksItems( $sk, &$content_navigation ) {
// For logged-in users in modern Vector, rearrange some links in the personal toolbar.
if ( $sk->getUser()->isRegistered() ) {
// user-menu may not be present e.g. during an edit.
if ( $sk->getUser()->isRegistered() && in_array( 'user-menu', $content_navigation ) ) {
// Remove user page from personal menu dropdown for logged in users at higher resolutions.
self::makeMenuItemCollapsible(
$content_navigation['user-menu']['userpage']