From b3e0ca374d23387ee389558d31f33a7b0f887477 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Thu, 20 Oct 2011 03:03:45 +0000 Subject: [PATCH] * Simplified r100286 by just using the field 'user_name' and removed the COALESCE * Simplified contribs pager with Revision::selectFields() --- includes/HistoryPage.php | 4 ++-- includes/Revision.php | 12 +++++++----- includes/RevisionList.php | 2 +- includes/revisiondelete/RevisionDelete.php | 2 +- includes/specials/SpecialContributions.php | 22 +++++++++++----------- includes/specials/SpecialMergeHistory.php | 4 ++-- 6 files changed, 24 insertions(+), 22 deletions(-) diff --git a/includes/HistoryPage.php b/includes/HistoryPage.php index f4b888fbb4..a34cafdefb 100644 --- a/includes/HistoryPage.php +++ b/includes/HistoryPage.php @@ -388,8 +388,8 @@ class HistoryPager extends ReverseChronologicalPager { $batch = new LinkBatch(); # Give some pointers to make (last) links foreach ( $this->mResult as $row ) { - $batch->addObj( Title::makeTitleSafe( NS_USER, $row->rev_user_name ) ); - $batch->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->rev_user_name ) ); + $batch->addObj( Title::makeTitleSafe( NS_USER, $row->user_name ) ); + $batch->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->user_name ) ); } $batch->execute(); $this->mResult->seek( 0 ); diff --git a/includes/Revision.php b/includes/Revision.php index a379d88954..ba885dc0bd 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -327,7 +327,7 @@ class Revision { * Return the list of user fields that should be selected from user table */ public static function selectUserFields() { - return array( 'COALESCE(user_name,rev_user_text) AS rev_user_name' ); + return array( 'user_name' ); } /** @@ -376,10 +376,12 @@ class Revision { $this->mTextRow = null; } - if ( isset( $row->rev_user_name ) ) { - $this->mUserText = $row->rev_user_name; // current user name - } else { // fallback to rev_user_text - $this->mUserText = $row->rev_user_text; // de-normalized + // Use user_name for users and rev_user_text for IPs. + // Also fallback to rev_user_text if user_name not given. + if ( isset( $row->user_name ) ) { + $this->mUserText = $row->user_name; // logged-in user (ideally) + } else { + $this->mUserText = $row->rev_user_text; // IP user (ideally) } } elseif( is_array( $row ) ) { // Build a new revision to be saved... diff --git a/includes/RevisionList.php b/includes/RevisionList.php index 6022b98098..2781764453 100644 --- a/includes/RevisionList.php +++ b/includes/RevisionList.php @@ -295,7 +295,7 @@ class RevisionItem extends RevisionItemBase { } public function getAuthorNameField() { - return 'rev_user_name'; // see Revision::selectUserFields() + return 'user_name'; // see Revision::selectUserFields() } public function canView() { diff --git a/includes/revisiondelete/RevisionDelete.php b/includes/revisiondelete/RevisionDelete.php index 1f320797de..8aeec556a4 100644 --- a/includes/revisiondelete/RevisionDelete.php +++ b/includes/revisiondelete/RevisionDelete.php @@ -131,7 +131,7 @@ class RevDel_RevisionItem extends RevDel_Item { } public function getAuthorNameField() { - return 'rev_user_name'; // see Revision::selectUserFields() + return 'user_name'; // see Revision::selectUserFields() } public function canView() { diff --git a/includes/specials/SpecialContributions.php b/includes/specials/SpecialContributions.php index 1885b53175..307181cbc7 100644 --- a/includes/specials/SpecialContributions.php +++ b/includes/specials/SpecialContributions.php @@ -481,15 +481,15 @@ class ContribsPager extends ReverseChronologicalPager { $join_cond['user'] = array( 'LEFT JOIN', 'rev_user != 0 AND user_id = rev_user' ); $queryInfo = array( - 'tables' => $tables, - 'fields' => array_merge( Revision::selectUserFields(), array( - 'page_namespace', 'page_title', 'page_is_new', 'page_latest', 'page_is_redirect', - 'page_len', 'rev_id', 'rev_page', 'rev_text_id', 'rev_timestamp', 'rev_comment', - 'rev_minor_edit', 'rev_user', 'rev_user_text', 'rev_parent_id', 'rev_deleted', - 'rev_len' - ) ), - 'conds' => $conds, - 'options' => array( 'USE INDEX' => array('revision' => $index) ), + 'tables' => $tables, + 'fields' => array_merge( + Revision::selectFields(), + Revision::selectUserFields(), + array( 'page_namespace', 'page_title', 'page_is_new', + 'page_latest', 'page_is_redirect', 'page_len' ) + ), + 'conds' => $conds, + 'options' => array( 'USE INDEX' => array( 'revision' => $index ) ), 'join_conds' => $join_cond ); @@ -567,8 +567,8 @@ class ContribsPager extends ReverseChronologicalPager { $batch = new LinkBatch(); # Give some pointers to make (last) links foreach ( $this->mResult as $row ) { - $batch->addObj( Title::makeTitleSafe( NS_USER, $row->rev_user_name ) ); - $batch->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->rev_user_name ) ); + $batch->addObj( Title::makeTitleSafe( NS_USER, $row->user_name ) ); + $batch->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->user_name ) ); } $batch->execute(); $this->mResult->seek( 0 ); diff --git a/includes/specials/SpecialMergeHistory.php b/includes/specials/SpecialMergeHistory.php index 2d86131a6c..f201a71a0a 100644 --- a/includes/specials/SpecialMergeHistory.php +++ b/includes/specials/SpecialMergeHistory.php @@ -452,8 +452,8 @@ class MergeHistoryPager extends ReverseChronologicalPager { # Give some pointers to make (last) links $this->mForm->prevId = array(); foreach ( $this->mResult as $row ) { - $batch->addObj( Title::makeTitleSafe( NS_USER, $row->rev_user_name ) ); - $batch->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->rev_user_name ) ); + $batch->addObj( Title::makeTitleSafe( NS_USER, $row->user_name ) ); + $batch->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->user_name ) ); $rev_id = isset( $rev_id ) ? $rev_id : $row->rev_id; if( $rev_id > $row->rev_id ) { -- 2.20.1