Legoktm has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/204947

Change subject: LocalRenameUserJob: In force mode, bypass all Title/User 
validation
......................................................................

LocalRenameUserJob: In force mode, bypass all Title/User validation

Just hit the DB directly when dealing with invalid usernames, and use
User::newFromRow() which does no validation/normalization.

Change-Id: Ida452110c95b2d5d785ad4ef8ec4d891bbf27cf1
(cherry picked from commit 2f9e4550c1a6561e1d2a655105bbd9591a544b2f)
---
M includes/LocalRenameJob/LocalRenameUserJob.php
1 file changed, 11 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralAuth 
refs/changes/47/204947/1

diff --git a/includes/LocalRenameJob/LocalRenameUserJob.php 
b/includes/LocalRenameJob/LocalRenameUserJob.php
index 52b9399..bd8a563 100644
--- a/includes/LocalRenameJob/LocalRenameUserJob.php
+++ b/includes/LocalRenameJob/LocalRenameUserJob.php
@@ -39,11 +39,18 @@
                        $callback = RequestContext::importScopedSession( 
$this->params['session'] );
                }
 
-               $oldUser = User::newFromName( $from );
                if ( isset( $this->params['force'] ) && $this->params['force'] 
) {
-                       // Forcibly set the username, don't validate it at all 
in case we're renaming
-                       // someone with an invalid username
-                       $oldUser->mName = $from;
+                       // If we're dealing with an invalid username, load the 
data ourselves to avoid
+                       // any normalization at all done by User or Title.
+                       $row = wfGetDB( DB_MASTER )->selectRow(
+                               'user',
+                               User::selectFields(),
+                               array( 'user_name' => $from ),
+                               __METHOD__
+                       );
+                       $oldUser = User::newFromRow( $row );
+               } else {
+                       $oldUser = User::newFromName( $from );
                }
 
                $rename = new RenameuserSQL(

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ida452110c95b2d5d785ad4ef8ec4d891bbf27cf1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CentralAuth
Gerrit-Branch: wmf/1.26wmf1
Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to