r35211 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r35210‎ | r35211 | r35212 >
Date:23:39, 22 May 2008
Author:aaron
Status:old
Tags:
Comment:
* If this user is renaming his/herself, make sure that Title::moveTo()
doesn't make a bunch of null move edits under the old name! (bug 14219)
* Break some really fucking long lines
* And what is this ampersand for?
* Add comment
Modified paths:
  • /trunk/extensions/Renameuser/SpecialRenameuser_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Renameuser/SpecialRenameuser_body.php
@@ -44,7 +44,8 @@
4545
4646 $showBlockLog = $wgRequest->getBool( 'submit-showBlockLog' );
4747 $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 );
4950 $oun = is_object( $oldusername ) ? $oldusername->getText() : '';
5051 $nun = is_object( $newusername ) ? $newusername->getText() : '';
5152 $token = $wgUser->editToken();
@@ -66,7 +67,8 @@
6768 "</td>
6869 <td class='mw-input'>" .
6970 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' ) ) . ' ' .
7173 "</td>
7274 </tr>
7375 <tr>
@@ -219,14 +221,23 @@
220222
221223 $rename = new RenameuserSQL( $oldusername->getText(), $newusername->getText(), $uid );
222224 $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+ }
223232
224233 $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() );
226236
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\" />" );
228239
229240 if ( $wgRequest->getCheck( 'movepages' ) && $wgUser->isAllowed( 'move' ) && version_compare( $wgVersion, '1.9alpha', '>=' ) ) {
230 - $dbr =& wfGetDB( DB_SLAVE );
 241+ $dbr = wfGetDB( DB_SLAVE );
231242 $oldkey = $oldusername->getDBkey();
232243 $pages = $dbr->select(
233244 'page',
@@ -244,12 +255,15 @@
245256 $skin =& $wgUser->getSkin();
246257 while ( $row = $dbr->fetchObject( $pages ) ) {
247258 $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
249262 if ( $newPage->exists() && !$oldPage->isValidMoveTarget( $newPage ) ) {
250263 $link = $skin->makeKnownLinkObj( $newPage );
251264 $output .= '<li class="mw-renameuser-pe">' . wfMsgHtml( 'renameuser-page-exists', $link ) . '</li>';
252265 } 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() ) );
254268 if( $success === true ) {
255269 $oldLink = $skin->makeKnownLinkObj( $oldPage, '', 'redirect=no' );
256270 $newLink = $skin->makeKnownLinkObj( $newPage );
@@ -266,6 +280,8 @@
267281 }
268282 }
269283
 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?
270286 function showLogExtract( $username, $type, &$out ) {
271287 global $wgOut;
272288 # Show relevant lines from the logs:

Status & tagging log