fixes Bug 34198 - first item in the history shows no information about its size
authorMark A. Hershberger <mah@users.mediawiki.org>
Sat, 11 Feb 2012 18:11:01 +0000 (18:11 +0000)
committerMark A. Hershberger <mah@users.mediawiki.org>
Sat, 11 Feb 2012 18:11:01 +0000 (18:11 +0000)
Regression in 1.19 found and fixed by Umherirrender

    With MediaWiki 1.19 the history page was changed from showing the
    size to showing the diff and giving the size in the tooltip.

    But now the first item in the history has no information about it size.

includes/actions/HistoryAction.php
includes/specials/SpecialContributions.php

index d64d3cb..0d82c33 100644 (file)
@@ -385,8 +385,13 @@ class HistoryPager extends ReverseChronologicalPager {
                $this->mResult->seek( 0 );
                $batch = new LinkBatch();
                foreach ( $this->mResult as $row ) {
-                       $batch->addObj( Title::makeTitleSafe( NS_USER, $row->user_name ) );
-                       $batch->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->user_name ) );
+                       if( !is_null( $row->user_name ) ) {
+                               $batch->add( NS_USER, $row->user_name );
+                               $batch->add( NS_USER_TALK, $row->user_name );
+                       } else { # for anons or usernames of imported revisions
+                               $batch->add( NS_USER, $row->rev_user_text );
+                               $batch->add( NS_USER_TALK, $row->rev_user_text );
+                       }
                }
                $batch->execute();
                $this->mResult->seek( 0 );
@@ -568,13 +573,10 @@ class HistoryPager extends ReverseChronologicalPager {
                        $s .= ' ' . ChangesList::flag( 'minor' );
                }
 
-               if ( $prevRev
-                       && !$prevRev->isDeleted( Revision::DELETED_TEXT )
-                       && !$rev->isDeleted( Revision::DELETED_TEXT ) )
-               {
-                       $sDiff = ChangesList::showCharacterDifference( $prevRev->getSize(), $rev->getSize() );
-                       $s .= ' . . ' . $sDiff . ' . . ';
-               }
+               # Size is always public data
+               $prevSize = $prevRev ? $prevRev->getSize() : 0;
+               $sDiff = ChangesList::showCharacterDifference( $prevSize, $rev->getSize() );
+               $s .= ' . . ' . $sDiff . ' . . ';
 
                $s .= Linker::revComment( $rev, false, true );
 
index f538abb..3471003 100644 (file)
@@ -511,9 +511,9 @@ class SpecialContributions extends SpecialPage {
                                        $filterSelection .
                                Xml::closeElement( 'tr' ) .
                                Xml::openElement( 'tr' ) .
-                                       $extraOptions .
-                               Xml::closeElement( 'tr' ) .
-                               Xml::openElement( 'tr' ) .
+                                       $extraOptions .
+                               Xml::closeElement( 'tr' ) .
+                               Xml::openElement( 'tr' ) .
                                        $dateSelectionAndSubmit .
                                Xml::closeElement( 'tr' ) .
                        Xml::closeElement( 'table' );
@@ -677,23 +677,26 @@ class ContribsPager extends ReverseChronologicalPager {
                $this->mResult->rewind();
                $revIds = array();
                foreach ( $this->mResult as $row ) {
-                       $revIds[] = $row->rev_parent_id;
+                       if( $row->rev_parent_id ) {
+                               $revIds[] = $row->rev_parent_id;
+                       }
                }
                $this->mParentLens = $this->getParentLengths( $revIds );
                $this->mResult->rewind(); // reset
 
-               if ( $this->contribs === 'newbie' ) { // multiple users
-                       # Do a link batch query
-                       $this->mResult->seek( 0 );
-                       $batch = new LinkBatch();
-                       # Give some pointers to make (last) links
-                       foreach ( $this->mResult as $row ) {
-                               $batch->addObj( Title::makeTitleSafe( NS_USER, $row->user_name ) );
-                               $batch->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->user_name ) );
+               # Do a link batch query
+               $this->mResult->seek( 0 );
+               $batch = new LinkBatch();
+               # Give some pointers to make (last) links
+               foreach ( $this->mResult as $row ) {
+                       if ( $this->contribs === 'newbie' ) { // multiple users
+                               $batch->add( NS_USER, $row->user_name );
+                               $batch->add( NS_USER_TALK, $row->user_name );
                        }
-                       $batch->execute();
-                       $this->mResult->seek( 0 );
+                       $batch->add( $row->page_namespace, $row->page_title );
                }
+               $batch->execute();
+               $this->mResult->seek( 0 );
        }
 
        /**
@@ -789,12 +792,9 @@ class ContribsPager extends ReverseChronologicalPager {
                        array( 'action' => 'history' )
                );
 
-               if ( isset( $this->mParentLens[$row->rev_parent_id] ) ) {
-                       $chardiff = ' . . ' . ChangesList::showCharacterDifference(
-                               $this->mParentLens[$row->rev_parent_id], $row->rev_len ) . ' . . ';
-               } else {
-                       $chardiff = ' ';
-               }
+               $parentLen = isset( $this->mParentLens[$row->rev_parent_id] ) ? $this->mParentLens[$row->rev_parent_id] : 0;
+               $chardiff = ' . . ' . ChangesList::showCharacterDifference(
+                               $parentLen, $row->rev_len ) . ' . . ';
 
                $lang = $this->getLanguage();
                $comment = $lang->getDirMark() . Linker::revComment( $rev, false, true );