Index: trunk/extensions/Renameuser/SpecialRenameuser_body.php |
— | — | @@ -44,7 +44,8 @@ |
45 | 45 | |
46 | 46 | $showBlockLog = $wgRequest->getBool( 'submit-showBlockLog' ); |
47 | 47 | $oldusername = Title::newFromText( $wgRequest->getText( 'oldusername' ), NS_USER ); |
48 | | - $newusername = Title::newFromText( $wgContLang->ucfirst( $wgRequest->getText( 'newusername' ) ), NS_USER ); // Force uppercase of newusername otherweise wikis with wgCapitalLinks=false can create lc usernames |
| 48 | + // Force uppercase of newusername otherweise wikis with wgCapitalLinks=false can create lc usernames |
| 49 | + $newusername = Title::newFromText( $wgContLang->ucfirst( $wgRequest->getText( 'newusername' ) ), NS_USER ); |
49 | 50 | $oun = is_object( $oldusername ) ? $oldusername->getText() : ''; |
50 | 51 | $nun = is_object( $newusername ) ? $newusername->getText() : ''; |
51 | 52 | $token = $wgUser->editToken(); |
— | — | @@ -66,7 +67,8 @@ |
67 | 68 | "</td> |
68 | 69 | <td class='mw-input'>" . |
69 | 70 | Xml::input( 'oldusername', 20, $oun, array( 'type' => 'text', 'tabindex' => '1' ) ) . ' ' . |
70 | | - Xml::submitButton( wfMsg( 'blocklogpage' ), array ( 'name' => 'submit-showBlockLog', 'id' => 'submit-showBlockLog', 'tabindex' => '2' ) ) . ' ' . |
| 71 | + Xml::submitButton( wfMsg( 'blocklogpage' ), array ( 'name' => 'submit-showBlockLog', |
| 72 | + 'id' => 'submit-showBlockLog', 'tabindex' => '2' ) ) . ' ' . |
71 | 73 | "</td> |
72 | 74 | </tr> |
73 | 75 | <tr> |
— | — | @@ -219,14 +221,23 @@ |
220 | 222 | |
221 | 223 | $rename = new RenameuserSQL( $oldusername->getText(), $newusername->getText(), $uid ); |
222 | 224 | $rename->rename(); |
| 225 | + |
| 226 | + // If this user is renaming his/herself, make sure that Title::moveTo() |
| 227 | + // doesn't make a bunch of null move edits under the old name! |
| 228 | + global $wgUser; |
| 229 | + if( $wgUser->getId() == $uid ) { |
| 230 | + $wgUser->setName( $newusername->getText() ); |
| 231 | + } |
223 | 232 | |
224 | 233 | $log = new LogPage( 'renameuser' ); |
225 | | - $log->addEntry( 'renameuser', $oldusername, wfMsgExt( 'renameuser-log', array( 'parsemag', 'content' ), $wgContLang->formatNum( $contribs ), $reason ), $newusername->getText() ); |
| 234 | + $log->addEntry( 'renameuser', $oldusername, wfMsgExt( 'renameuser-log', array( 'parsemag', 'content' ), |
| 235 | + $wgContLang->formatNum( $contribs ), $reason ), $newusername->getText() ); |
226 | 236 | |
227 | | - $wgOut->addWikiText( "<div class=\"successbox\">" . wfMsg( 'renameusersuccess', $oldusername->getText(), $newusername->getText() ) . "</div><br style=\"clear:both\" />" ); |
| 237 | + $wgOut->addWikiText( "<div class=\"successbox\">" . wfMsg( 'renameusersuccess', $oldusername->getText(), |
| 238 | + $newusername->getText() ) . "</div><br style=\"clear:both\" />" ); |
228 | 239 | |
229 | 240 | if ( $wgRequest->getCheck( 'movepages' ) && $wgUser->isAllowed( 'move' ) && version_compare( $wgVersion, '1.9alpha', '>=' ) ) { |
230 | | - $dbr =& wfGetDB( DB_SLAVE ); |
| 241 | + $dbr = wfGetDB( DB_SLAVE ); |
231 | 242 | $oldkey = $oldusername->getDBkey(); |
232 | 243 | $pages = $dbr->select( |
233 | 244 | 'page', |
— | — | @@ -244,12 +255,15 @@ |
245 | 256 | $skin =& $wgUser->getSkin(); |
246 | 257 | while ( $row = $dbr->fetchObject( $pages ) ) { |
247 | 258 | $oldPage = Title::makeTitleSafe( $row->page_namespace, $row->page_title ); |
248 | | - $newPage = Title::makeTitleSafe( $row->page_namespace, preg_replace( '!^[^/]+!', $newusername->getDBkey(), $row->page_title ) ); |
| 259 | + $newPage = Title::makeTitleSafe( $row->page_namespace, |
| 260 | + preg_replace( '!^[^/]+!', $newusername->getDBkey(), $row->page_title ) ); |
| 261 | + # Do not autodelete or anything, title must not exist |
249 | 262 | if ( $newPage->exists() && !$oldPage->isValidMoveTarget( $newPage ) ) { |
250 | 263 | $link = $skin->makeKnownLinkObj( $newPage ); |
251 | 264 | $output .= '<li class="mw-renameuser-pe">' . wfMsgHtml( 'renameuser-page-exists', $link ) . '</li>'; |
252 | 265 | } else { |
253 | | - $success = $oldPage->moveTo( $newPage, false, wfMsgForContent( 'renameuser-move-log', $oldusername->getText(), $newusername->getText() ) ); |
| 266 | + $success = $oldPage->moveTo( $newPage, false, wfMsgForContent( 'renameuser-move-log', |
| 267 | + $oldusername->getText(), $newusername->getText() ) ); |
254 | 268 | if( $success === true ) { |
255 | 269 | $oldLink = $skin->makeKnownLinkObj( $oldPage, '', 'redirect=no' ); |
256 | 270 | $newLink = $skin->makeKnownLinkObj( $newPage ); |
— | — | @@ -266,6 +280,8 @@ |
267 | 281 | } |
268 | 282 | } |
269 | 283 | |
| 284 | + // FIXME: this code is total crap. Should this just use LogEventsList or |
| 285 | + // since extensions are branched, or are we keeping the half-ass b/c thing? |
270 | 286 | function showLogExtract( $username, $type, &$out ) { |
271 | 287 | global $wgOut; |
272 | 288 | # Show relevant lines from the logs: |