Index: trunk/extensions/Renameuser/SpecialRenameuser.php |
— | — | @@ -33,8 +33,8 @@ |
34 | 34 | 'renameusernew' => 'New username: ', |
35 | 35 | 'renameusersubmit' => 'Submit', |
36 | 36 | |
37 | | - 'renameusererrordoesnotexist' => 'The username "<nowiki>$1</nowiki>" does not exist', |
38 | | - 'renameusererrorexists' => 'The username "<nowiki>$1</nowiki>" already exits', |
| 37 | + 'renameusererrordoesnotexist' => 'The user "<nowiki>$1</nowiki>" does not exist', |
| 38 | + 'renameusererrorexists' => 'The user "<nowiki>$1</nowiki>" already exits', |
39 | 39 | 'renameusererrorinvalid' => 'The username "<nowiki>$1</nowiki>" is invalid', |
40 | 40 | 'renameusererrortoomany' => 'The user "<nowiki>$1</nowiki>" has $2 contributions, renaming a user with more ' . |
41 | 41 | 'than $3 contributions could adversely affect site performance', |
— | — | @@ -64,7 +64,7 @@ |
65 | 65 | |
66 | 66 | $this->setHeaders(); |
67 | 67 | |
68 | | - if ( ! $wgUser->isAllowed( 'renameuser' ) ) { |
| 68 | + if ( !$wgUser->isAllowed( 'renameuser' ) ) { |
69 | 69 | $wgOut->permissionRequired( 'renameuser' ); |
70 | 70 | return; |
71 | 71 | } |
— | — | @@ -79,12 +79,14 @@ |
80 | 80 | return; |
81 | 81 | } |
82 | 82 | |
83 | | - $oldusername = $wgContLang->ucfirst( strtr( trim( $wgRequest->getText( 'oldusername' ) ), '_', ' ' ) ); |
84 | | - $newusername = $wgContLang->ucfirst( strtr( trim( $wgRequest->getText( 'newusername' ) ), '_', ' ' ) ); |
| 83 | + $oldusername = Title::newFromText( $wgRequest->getText( 'oldusername' ) ); |
| 84 | + $newusername = Title::newFromText( $wgRequest->getText( 'newusername' ) ); |
85 | 85 | |
86 | 86 | $action = $wgTitle->escapeLocalUrl(); |
87 | 87 | $renameuserold = wfMsgHtml( 'renameuserold' ); |
88 | 88 | $renameusernew = wfMsgHtml( 'renameusernew' ); |
| 89 | + $oun = is_object( $oldusername ) ? $oldusername->getText() : ''; |
| 90 | + $nun = is_object( $newusername ) ? $newusername->getText() : ''; |
89 | 91 | $submit = wfMsgHtml( 'renameusersubmit' ); |
90 | 92 | $token = $wgUser->editToken(); |
91 | 93 | |
— | — | @@ -93,11 +95,11 @@ |
94 | 96 | <table> |
95 | 97 | <tr> |
96 | 98 | <td align='right'>$renameuserold</td> |
97 | | - <td align='left'><input tabindex='1' type='text' size='20' name='oldusername' value=\"" . htmlspecialchars($oldusername) . "\" /></td> |
| 99 | + <td align='left'><input tabindex='1' type='text' size='20' name='oldusername' value=\"$oun\" /></td> |
98 | 100 | </tr> |
99 | 101 | <tr> |
100 | 102 | <td align='right'>$renameusernew</td> |
101 | | - <td align='left'><input tabindex='1' type='text' size='20' name='newusername' value=\"" . htmlspecialchars($newusername) . "\"/></td> |
| 103 | + <td align='left'><input tabindex='1' type='text' size='20' name='newusername' value=\"$nun\"/></td> |
102 | 104 | </tr> |
103 | 105 | <tr> |
104 | 106 | <td> </td> |
— | — | @@ -110,33 +112,33 @@ |
111 | 113 | if ( !$wgRequest->wasPosted() || !$wgUser->matchEditToken( $wgRequest->getVal( 'token' ) ) ) |
112 | 114 | return; |
113 | 115 | |
114 | | - if ($oldusername == '' || $newusername == '' || $oldusername == $newusername) |
| 116 | + if ( !is_object( $oldusername ) || !is_object( $newusername ) || $oldusername->getText() == $newusername->getText() ) |
115 | 117 | return; |
116 | 118 | |
117 | 119 | $wgOut->addHTML( '<hr />' ); |
118 | 120 | |
119 | | - $olduser = User::newFromName( $oldusername ); |
120 | | - $newuser = User::newFromName( $newusername ); |
| 121 | + $olduser = User::newFromName( $oldusername->getText() ); |
| 122 | + $newuser = User::newFromName( $newusername->getText() ); |
121 | 123 | |
122 | 124 | // It won't be an object if for instance "|" is supplied as a value |
123 | 125 | if ( !is_object( $olduser ) ) { |
124 | | - $wgOut->addWikiText( wfMsg( 'renameusererrorinvalid', $oldusername ) ); |
| 126 | + $wgOut->addWikiText( wfMsg( 'renameusererrorinvalid', $oldusername->getText() ) ); |
125 | 127 | return; |
126 | 128 | } |
127 | 129 | |
128 | 130 | if ( !is_object( $newuser ) ) { |
129 | | - $wgOut->addWikiText( wfMsg( 'renameusererrorinvalid', $newusername ) ); |
| 131 | + $wgOut->addWikiText( wfMsg( 'renameusererrorinvalid', $newusername->getText() ) ); |
130 | 132 | return; |
131 | 133 | } |
132 | 134 | |
133 | 135 | $uid = $olduser->idForName(); |
134 | 136 | if ($uid == 0) { |
135 | | - $wgOut->addWikiText( wfMsg( 'renameusererrordoesnotexist', $oldusername ) ); |
| 137 | + $wgOut->addWikiText( wfMsg( 'renameusererrordoesnotexist', $oldusername->getText() ) ); |
136 | 138 | return; |
137 | 139 | } |
138 | 140 | |
139 | 141 | if ($newuser->idForName() != 0) { |
140 | | - $wgOut->addWikiText( wfMsg( 'renameusererrorexists', $newusername ) ); |
| 142 | + $wgOut->addWikiText( wfMsg( 'renameusererrorexists', $newusername->getText() ) ); |
141 | 143 | return; |
142 | 144 | } |
143 | 145 | |
— | — | @@ -145,7 +147,7 @@ |
146 | 148 | if ( RENAMEUSER_CONTRIBLIMIT != 0 && $contribs > RENAMEUSER_CONTRIBLIMIT ) { |
147 | 149 | $wgOut->addWikiText( |
148 | 150 | wfMsg( 'renameusererrortoomany', |
149 | | - $oldusername, |
| 151 | + $oldusername->getText(), |
150 | 152 | $wgLang->formatNum( $contribs ), |
151 | 153 | $wgLang->formatNum( RENAMEUSER_CONTRIBLIMIT ) |
152 | 154 | ) |
— | — | @@ -153,13 +155,13 @@ |
154 | 156 | return; |
155 | 157 | } |
156 | 158 | |
157 | | - $rename = new RenameuserSQL( $oldusername, $newusername, $uid ); |
| 159 | + $rename = new RenameuserSQL( $oldusername->getText(), $newusername->getText(), $uid ); |
158 | 160 | $rename->rename(); |
159 | 161 | |
160 | 162 | $log = new LogPage( 'renameuser' ); |
161 | | - $log->addEntry( 'renameuser', $wgTitle, wfMsg( 'renameuserlog', $oldusername, $newusername, $contribs ) ); |
| 163 | + $log->addEntry( 'renameuser', $wgTitle, wfMsg( 'renameuserlog', $oldusername->getText(), $newusername->getText(), $contribs ) ); |
162 | 164 | |
163 | | - $wgOut->addWikiText( wfMsg( 'renameusersuccess', $oldusername, $newusername ) ); |
| 165 | + $wgOut->addWikiText( wfMsg( 'renameusersuccess', $oldusername->getText(), $newusername->getText() ) ); |
164 | 166 | } |
165 | 167 | } |
166 | 168 | |
— | — | @@ -240,13 +242,13 @@ |
241 | 243 | ); |
242 | 244 | } |
243 | 245 | |
244 | | - # Update user_touched and clear user cache |
245 | 246 | $dbw->update( 'user', |
246 | 247 | array( 'user_touched' => $dbw->timestamp() ), |
247 | 248 | array( 'user_name' => $this->new ), |
248 | 249 | $fname |
249 | 250 | ); |
250 | 251 | |
| 252 | + // Clear the user cache |
251 | 253 | $wgMemc->delete( "$wgDBname:user:id:{$this->uid}" ); |
252 | 254 | |
253 | 255 | wfProfileOut( $fname ); |