From cd2a18646903df6d6cbb4703158cd85e3e31a99c Mon Sep 17 00:00:00 2001 From: Clare Ming Date: Tue, 17 Aug 2021 12:21:08 -0600 Subject: [PATCH] Do not show create account link for private wikis. - Add conditional to check for 'createaccount' permissions based on config. - Update relevant template to show/hide create account markup. Note that this solution excludes the use case of extensions using core hooks to disable account creation. See https://phabricator.wikimedia.org/T288428#7303233. Bug: T288428 Change-Id: I89852207ee42f5ddd07e5dd6141461c6bfbcd5ac --- includes/SkinVector.php | 9 +++++++++ includes/templates/UserLinks__more.mustache | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/includes/SkinVector.php b/includes/SkinVector.php index ed87451..1be8fbb 100644 --- a/includes/SkinVector.php +++ b/includes/SkinVector.php @@ -263,8 +263,17 @@ class SkinVector extends SkinMustache { ], false ); $templateParser = $this->getTemplateParser(); + // See T288428#7303233. The following conditional checks whether config is disabling account creation for + // anonymous users in modern Vector. This check excludes the use case of extensions using core and legacy hooks + // to remove the "Create account" link from the personal toolbar. Ideally this should be managed with a new hook + // that tracks account creation ability. + // Supporting removing items via hook involves unnecessary additional complexity we'd rather avoid at this time. + // (see https://gerrit.wikimedia.org/r/c/mediawiki/skins/Vector/+/713505/3) + // Account creation can be disabled by setting `$wgGroupPermissions['*']['createaccount'] = false;` + $isCreateAccountAllowed = $isAnon && $this->getAuthority()->isAllowed( 'createaccount' ); $userMoreHtmlItems = $templateParser->processTemplate( 'UserLinks__more', [ 'is-anon' => $isAnon, + 'is-create-account-allowed' => $isCreateAccountAllowed, 'html-create-account' => $htmlCreateAccount, 'data-user-interface-preferences' => $menuData[ 'data-user-interface-preferences' ], 'data-notifications' => $menuData[ 'data-notifications' ], diff --git a/includes/templates/UserLinks__more.mustache b/includes/templates/UserLinks__more.mustache index 9a0f921..150f3f3 100644 --- a/includes/templates/UserLinks__more.mustache +++ b/includes/templates/UserLinks__more.mustache @@ -1,9 +1,9 @@ {{#data-user-interface-preferences}}{{{html-items}}}{{/data-user-interface-preferences}} -{{#is-anon}} +{{#is-create-account-allowed}} -{{/is-anon}} +{{/is-create-account-allowed}} {{^is-anon}} {{#data-user-page}}{{{html-items}}}{{/data-user-page}} {{#data-notifications}}{{{html-items}}}{{/data-notifications}}