jenkins-bot has submitted this change and it was merged.

Change subject: GlobalRename: show message if new username matches a title 
blacklist entry
......................................................................


GlobalRename: show message if new username matches a title blacklist entry

Bug: T131703
Change-Id: Ic884dcb7832946afcfebd06fa11d6ced1de1554e
---
M i18n/en.json
M i18n/qqq.json
M includes/specials/SpecialGlobalRenameQueue.php
M includes/specials/SpecialGlobalRenameUser.php
4 files changed, 50 insertions(+), 1 deletion(-)

Approvals:
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/i18n/en.json b/i18n/en.json
index 983e497..5053888 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -369,8 +369,10 @@
        "centralauth-rename-form-movepages" : "Move user pages",
        "centralauth-rename-form-suppressredirects" : "Suppress creation of 
redirects",
        "centralauth-rename-form-overrideantispoof": "Override any AntiSpoof 
conflicts",
+       "centralauth-rename-form-overridetitleblacklist": "Override 
TitleBlacklist",
        "centralauth-rename-form-allowhigheditcount": "Confirm to rename user 
with more than $1 {{PLURAL:$1|edit|edits}}",
        "centralauth-rename-globaleditcount-threshold": "This user has more 
than $1 {{PLURAL:$1|edit|edits}}. Please confirm that you are sure that you 
want to rename this user and that a system administrator is available to 
monitor this rename.",
+       "centralauth-rename-titleblacklist-match": "The new username matches 
the following TitleBlacklist entry: $1",
        "centralauth-rename-notinstalled" : "The Renameuser extension is not 
installed.",
        "centralauth-rename-doesnotexist" : "The provided account does not 
exist.",
        "centralauth-rename-alreadyexists" : "The requested username already 
exists.",
@@ -477,6 +479,7 @@
        "globalrenamequeue-request-unknown-body": "The rename request was not 
found.",
        "globalrenamequeue-request-status-title": "Rename from \"$1\" to 
\"$2\"",
        "globalrenamequeue-request-antispoof-conflicts": "<strong>The chosen 
username is similar to {{PLURAL:$2|an existing username|existing 
usernames}}:</strong> $1",
+       "globalrenamequeue-request-titleblacklist": "<strong>The chosen 
username matches the following title blacklist entry:</strong> $1",
        "globalrenamequeue-request-previous-renames": "Previous 
{{PLURAL:$1|rename|renames}}",
        "globalrenamequeue-view": 
";From:\n:[[Special:CentralAuth/$1|$1]]\n;To:\n:[[Special:CentralAuth/$2|$2]]\n;Reason:\n:$3\n;Status:\n:$4\n;Requested:\n:$5\n;Completed:\n:$6\n;Done
 by:\n:[$7 $8]\n;Notes:\n:$9",
        "globalrenamequeue-view-approved": "approved",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index e5edb04..e0069ba 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -385,8 +385,10 @@
        "centralauth-rename-form-movepages": "Label for checkbox of whether to 
move the user\"s userpages",
        "centralauth-rename-form-suppressredirects": "Label for checkbox of 
whether to suppress redirects when moving the user\"s userpages",
        "centralauth-rename-form-overrideantispoof": "Label for checkbox on 
whether to override any AntiSpoof conflicts",
+       "centralauth-rename-form-overridetitleblacklist": "Label for checkbox 
on whether to override TitleBlacklist",
        "centralauth-rename-form-allowhigheditcount": "Label for checkbox 
asking for confirmation to globally rename a user with more than a certain 
number of edits. $1 is this edit count threshold.",
        "centralauth-rename-globaleditcount-threshold": "Message shown on 
Special:GlobalRenameUser if the user has more than a certain number of edits. 
$1 is the number of edits.",
+       "centralauth-rename-titleblacklist-match": "Message shown on 
Special:GlobalRenameUser if the new username matches a 
[[mw:Extension:TitleBlacklist]] entry.",
        "centralauth-rename-notinstalled": "Error message if the RenameUser 
extension is not installed.",
        "centralauth-rename-doesnotexist": "Error message if the account 
provided does not exist.",
        "centralauth-rename-alreadyexists": "Error message if there is already 
an account at the new username.",
@@ -493,6 +495,7 @@
        "globalrenamequeue-request-unknown-body": "Page content when an invalid 
URL is requested.",
        "globalrenamequeue-request-status-title": "Page title when viewing 
processed request.",
        "globalrenamequeue-request-antispoof-conflicts": "Informational message 
shown when a user's requested name is similar to other existing usernames. $1 
is a comma separated list of usernames, $2 is the number of usernames for 
PLURAL support.",
+       "globalrenamequeue-request-titleblacklist": "Message shown when a 
user's requested name matches a [[mw:Extension:TitleBlacklist|title blacklist]] 
entry. $1 is the regular expression which matched the username.",
        "globalrenamequeue-request-previous-renames": "Text for fieldset label 
surrounding log entries of the requesting username's previous renames. $1 is 
the number of log entries for PLURAL.",
        "globalrenamequeue-view": "Display a completed request.\n\n* $1 is the 
original user name.\n* $2 is the requested user name.\n* $3 is the reason for 
the rename request.\n* $4 is the status of the request.\n* $5 is the date and 
time the request was made.\n* $6 is the date and time the request was 
processed.\n* $7 is a link to the user page of the steward who processed the 
request.\n* $8 is the user name of the steward who processed the request.\n* $9 
is notes made by the steward.",
        "globalrenamequeue-view-approved": "Display text for an approved 
request.\n{{Identical|Approved}}",
diff --git a/includes/specials/SpecialGlobalRenameQueue.php 
b/includes/specials/SpecialGlobalRenameQueue.php
index af49af9..53b4314 100644
--- a/includes/specials/SpecialGlobalRenameQueue.php
+++ b/includes/specials/SpecialGlobalRenameQueue.php
@@ -417,7 +417,21 @@
                                        $this->msg(
                                                
'globalrenamequeue-request-antispoof-conflicts',
                                                
$this->getLanguage()->commaList( $conflicts )
-                                       )->numParams( count( $conflicts ) 
)->parse()
+                                       )->numParams( count( $conflicts ) 
)->parseAsBlock()
+                               );
+                       }
+               }
+
+               // Show a message if the new username matches the title 
blacklist.
+               if ( class_exists( 'TitleBlacklist' ) ) {
+                       $titleBlacklist = 
TitleBlacklist::singleton()->isBlacklisted(
+                               Title::makeTitleSafe( NS_USER, 
$req->getNewName() ),
+                               'new-account'
+                       );
+                       if ( $titleBlacklist instanceof TitleBlacklistEntry ) {
+                               $form->addHeaderText(
+                                       $this->msg( 
'globalrenamequeue-request-titleblacklist' )
+                                               ->rawParams( 
$titleBlacklist->getRegex() )->parseAsBlock()
                                );
                        }
                }
diff --git a/includes/specials/SpecialGlobalRenameUser.php 
b/includes/specials/SpecialGlobalRenameUser.php
index 37787ac..78b9757 100644
--- a/includes/specials/SpecialGlobalRenameUser.php
+++ b/includes/specials/SpecialGlobalRenameUser.php
@@ -23,6 +23,11 @@
        private $allowHighEditcount = false;
 
        /**
+        * @var bool
+        */
+       private $overrideTitleBlacklist = false;
+
+       /**
         * @const int Require confirmation if olduser has more than this many 
global edits
         */
        const EDITCOUNT_THRESHOLD = 50000;
@@ -84,6 +89,12 @@
                                'id' => 'mw-globalrenameuser-overrideantispoof',
                                'name' => 'overrideantispoof',
                                'label-message' => 
'centralauth-rename-form-overrideantispoof',
+                               'type' => 'check'
+                       ),
+                       'overridetitleblacklist' => array(
+                               'id' => 
'mw-globalrenameuser-overridetitleblacklist',
+                               'name' => 'overridetitleblacklist',
+                               'label-message' => 
'centralauth-rename-form-overridetitleblacklist',
                                'type' => 'check'
                        ),
                        'allowhigheditcount' => array(
@@ -163,6 +174,20 @@
                        );
                }
 
+               // Ask for confirmation if the new username matches the title 
blacklist.
+               if ( !$this->overrideTitleBlacklist && class_exists( 
'TitleBlacklist' ) ) {
+                               $titleBlacklist = 
TitleBlacklist::singleton()->isBlacklisted(
+                                       Title::makeTitleSafe( NS_USER, 
$newUser->getName() ),
+                                       'new-account'
+                               );
+                               if ( $titleBlacklist instanceof 
TitleBlacklistEntry ) {
+                                       return Status::newFatal(
+                                               $this->msg( 
'centralauth-rename-titleblacklist-match' )
+                                                       ->rawParams( 
$titleBlacklist->getRegex() )
+                                       );
+                               }
+               }
+
                $validator = new GlobalRenameUserValidator();
                $status = $validator->validate( $oldUser, $newUser );
 
@@ -202,6 +227,10 @@
                        $this->overrideAntiSpoof = true;
                }
 
+               if ( $data['overridetitleblacklist'] ) {
+                       $this->overrideTitleBlacklist = true;
+               }
+
                if ( $data['allowhigheditcount'] ) {
                        $this->allowHighEditcount = true;
                }

-- 
To view, visit https://gerrit.wikimedia.org/r/285078
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic884dcb7832946afcfebd06fa11d6ced1de1554e
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/CentralAuth
Gerrit-Branch: master
Gerrit-Owner: Glaisher <[email protected]>
Gerrit-Reviewer: Glaisher <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to