* Simplified r100286 by just using the field 'user_name' and removed the COALESCE
authorAaron Schulz <aaron@users.mediawiki.org>
Thu, 20 Oct 2011 03:03:45 +0000 (03:03 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Thu, 20 Oct 2011 03:03:45 +0000 (03:03 +0000)
* Simplified contribs pager with Revision::selectFields()

includes/HistoryPage.php
includes/Revision.php
includes/RevisionList.php
includes/revisiondelete/RevisionDelete.php
includes/specials/SpecialContributions.php
includes/specials/SpecialMergeHistory.php

index f4b888f..a34cafd 100644 (file)
@@ -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 );
index a379d88..ba885dc 100644 (file)
@@ -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...
index 6022b98..2781764 100644 (file)
@@ -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() {
index 1f32079..8aeec55 100644 (file)
@@ -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() {
index 1885b53..307181c 100644 (file)
@@ -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 );
index 2d86131..f201a71 100644 (file)
@@ -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 ) {