r100326 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100325‎ | r100326 | r100327 >
Date:03:03, 20 October 2011
Author:aaron
Status:ok
Tags:
Comment:
* Simplified r100286 by just using the field 'user_name' and removed the COALESCE
* Simplified contribs pager with Revision::selectFields()
Modified paths:
  • /trunk/phase3/includes/HistoryPage.php (modified) (history)
  • /trunk/phase3/includes/Revision.php (modified) (history)
  • /trunk/phase3/includes/RevisionList.php (modified) (history)
  • /trunk/phase3/includes/revisiondelete/RevisionDelete.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialContributions.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialMergeHistory.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/revisiondelete/RevisionDelete.php
@@ -131,7 +131,7 @@
132132 }
133133
134134 public function getAuthorNameField() {
135 - return 'rev_user_name'; // see Revision::selectUserFields()
 135+ return 'user_name'; // see Revision::selectUserFields()
136136 }
137137
138138 public function canView() {
Index: trunk/phase3/includes/HistoryPage.php
@@ -388,8 +388,8 @@
389389 $batch = new LinkBatch();
390390 # Give some pointers to make (last) links
391391 foreach ( $this->mResult as $row ) {
392 - $batch->addObj( Title::makeTitleSafe( NS_USER, $row->rev_user_name ) );
393 - $batch->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->rev_user_name ) );
 392+ $batch->addObj( Title::makeTitleSafe( NS_USER, $row->user_name ) );
 393+ $batch->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->user_name ) );
394394 }
395395 $batch->execute();
396396 $this->mResult->seek( 0 );
Index: trunk/phase3/includes/Revision.php
@@ -327,7 +327,7 @@
328328 * Return the list of user fields that should be selected from user table
329329 */
330330 public static function selectUserFields() {
331 - return array( 'COALESCE(user_name,rev_user_text) AS rev_user_name' );
 331+ return array( 'user_name' );
332332 }
333333
334334 /**
@@ -376,10 +376,12 @@
377377 $this->mTextRow = null;
378378 }
379379
380 - if ( isset( $row->rev_user_name ) ) {
381 - $this->mUserText = $row->rev_user_name; // current user name
382 - } else { // fallback to rev_user_text
383 - $this->mUserText = $row->rev_user_text; // de-normalized
 380+ // Use user_name for users and rev_user_text for IPs.
 381+ // Also fallback to rev_user_text if user_name not given.
 382+ if ( isset( $row->user_name ) ) {
 383+ $this->mUserText = $row->user_name; // logged-in user (ideally)
 384+ } else {
 385+ $this->mUserText = $row->rev_user_text; // IP user (ideally)
384386 }
385387 } elseif( is_array( $row ) ) {
386388 // Build a new revision to be saved...
Index: trunk/phase3/includes/specials/SpecialContributions.php
@@ -481,15 +481,15 @@
482482 $join_cond['user'] = array( 'LEFT JOIN', 'rev_user != 0 AND user_id = rev_user' );
483483
484484 $queryInfo = array(
485 - 'tables' => $tables,
486 - 'fields' => array_merge( Revision::selectUserFields(), array(
487 - 'page_namespace', 'page_title', 'page_is_new', 'page_latest', 'page_is_redirect',
488 - 'page_len', 'rev_id', 'rev_page', 'rev_text_id', 'rev_timestamp', 'rev_comment',
489 - 'rev_minor_edit', 'rev_user', 'rev_user_text', 'rev_parent_id', 'rev_deleted',
490 - 'rev_len'
491 - ) ),
492 - 'conds' => $conds,
493 - 'options' => array( 'USE INDEX' => array('revision' => $index) ),
 485+ 'tables' => $tables,
 486+ 'fields' => array_merge(
 487+ Revision::selectFields(),
 488+ Revision::selectUserFields(),
 489+ array( 'page_namespace', 'page_title', 'page_is_new',
 490+ 'page_latest', 'page_is_redirect', 'page_len' )
 491+ ),
 492+ 'conds' => $conds,
 493+ 'options' => array( 'USE INDEX' => array( 'revision' => $index ) ),
494494 'join_conds' => $join_cond
495495 );
496496
@@ -567,8 +567,8 @@
568568 $batch = new LinkBatch();
569569 # Give some pointers to make (last) links
570570 foreach ( $this->mResult as $row ) {
571 - $batch->addObj( Title::makeTitleSafe( NS_USER, $row->rev_user_name ) );
572 - $batch->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->rev_user_name ) );
 571+ $batch->addObj( Title::makeTitleSafe( NS_USER, $row->user_name ) );
 572+ $batch->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->user_name ) );
573573 }
574574 $batch->execute();
575575 $this->mResult->seek( 0 );
Index: trunk/phase3/includes/specials/SpecialMergeHistory.php
@@ -452,8 +452,8 @@
453453 # Give some pointers to make (last) links
454454 $this->mForm->prevId = array();
455455 foreach ( $this->mResult as $row ) {
456 - $batch->addObj( Title::makeTitleSafe( NS_USER, $row->rev_user_name ) );
457 - $batch->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->rev_user_name ) );
 456+ $batch->addObj( Title::makeTitleSafe( NS_USER, $row->user_name ) );
 457+ $batch->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->user_name ) );
458458
459459 $rev_id = isset( $rev_id ) ? $rev_id : $row->rev_id;
460460 if( $rev_id > $row->rev_id ) {
Index: trunk/phase3/includes/RevisionList.php
@@ -295,7 +295,7 @@
296296 }
297297
298298 public function getAuthorNameField() {
299 - return 'rev_user_name'; // see Revision::selectUserFields()
 299+ return 'user_name'; // see Revision::selectUserFields()
300300 }
301301
302302 public function canView() {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r100286* Tweaked Revision class to handle loading the current user name instead of r...aaron22:25, 19 October 2011

Status & tagging log