From 108aeb2d8862ce6ebac2581f1b43edb5818c1b04 Mon Sep 17 00:00:00 2001 From: ksarabia Date: Wed, 8 Mar 2023 13:50:20 -0600 Subject: [PATCH] Fixes missing account login in OfficeWiki Addresses missing login button and dropwdown by adjusting Hooks.php Bug: T329463 Change-Id: I0fa630f5fef7fdd651fda1331762ffefbb1c5b75 --- includes/Hooks.php | 23 +++++++++++++++---- tests/phpunit/integration/VectorHooksTest.php | 3 +-- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/includes/Hooks.php b/includes/Hooks.php index 9c927317d..c5275d48f 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -289,13 +289,17 @@ class Hooks implements if ( !$isRegistered ) { // Remove "Not logged in" from personal menu dropdown for anon users. unset( $content_navigation['user-menu']['anonuserpage'] ); - // Remove duplicate "Login" link added by SkinTemplate::buildPersonalUrls if group read permissions - // are set to false. - unset( $content_navigation['user-menu']['login-private'] ); // Make login and create account collapsible - $content_navigation['user-menu']['login']['collapsible'] = true; - $content_navigation['user-menu']['createaccount']['collapsible'] = true; + if ( isset( $content_navigation['user-menu']['login'] ) ) { + $content_navigation['user-menu']['login']['collapsible'] = true; + } + if ( isset( $content_navigation['user-menu']['login-private'] ) ) { + $content_navigation['user-menu']['login-private']['collapsible'] = true; + } + if ( isset( $content_navigation['user-menu']['createaccount'] ) ) { + $content_navigation['user-menu']['createaccount']['collapsible'] = true; + } // Anon editor links handled manually in new anon editor menu $anonEditorMenu = []; @@ -398,6 +402,15 @@ class Hooks implements 'icon' => '', ] ); } + if ( isset( $content_navigation['user-menu']['login-private'] ) ) { + $content_navigation[$overflow]['login-private'] = array_merge( + $content_navigation['user-menu']['login-private'], [ + 'id' => 'pt-login-private-2', + 'collapsible' => true, + // Remove icon + 'icon' => '', + ] ); + } self::updateMenuItems( $content_navigation, $overflow ); } diff --git a/tests/phpunit/integration/VectorHooksTest.php b/tests/phpunit/integration/VectorHooksTest.php index a6469e15e..42ddff29b 100644 --- a/tests/phpunit/integration/VectorHooksTest.php +++ b/tests/phpunit/integration/VectorHooksTest.php @@ -507,7 +507,6 @@ class VectorHooksTest extends MediaWikiIntegrationTestCase { 'anonuserpage' => [ 'class' => [], 'icon' => 'anonuserpage' ], 'createaccount' => [ 'class' => [], 'icon' => 'createaccount' ], 'login' => [ 'class' => [], 'icon' => 'login' ], - 'login-private' => [ 'class' => [], 'icon' => 'login-private' ], 'anontalk' => [ 'class' => [], 'icon' => 'anontalk' ], 'anoncontribs' => [ 'class' => [], 'icon' => 'anoncontribs' ], ], @@ -517,7 +516,7 @@ class VectorHooksTest extends MediaWikiIntegrationTestCase { count( $contentAnon['user-menu'] ) === 2 && isset( $contentAnon['user-menu']['createaccount'] ) && isset( $contentAnon['user-menu']['login'] ), - 'Anon user page, login private and anon talk, anon contribs links are removed from user-menu' + 'Anon user page, anon talk, anon contribs links are removed from user-menu' ); $this->assertTrue(