Merge "Resolve bug #18704 ("Add an unique CSS class or ID to the tagfilter table...
[lhc/web/wiklou.git] / includes / specials / SpecialContributions.php
index 7d55ce2..c598457 100644 (file)
@@ -71,12 +71,16 @@ class SpecialContributions extends SpecialPage {
                $this->opts['target'] = $target;
                $this->opts['topOnly'] = $request->getBool( 'topOnly' );
 
-               $userObj = User::newFromName( $target, false );
+               $nt = Title::makeTitleSafe( NS_USER, $target );
+               if ( !$nt ) {
+                       $out->addHTML( $this->getForm() );
+                       return;
+               }
+               $userObj = User::newFromName( $nt->getText(), false );
                if ( !$userObj ) {
                        $out->addHTML( $this->getForm() );
                        return;
                }
-               $nt = $userObj->getUserPage();
                $id = $userObj->getID();
 
                if ( $this->opts['contribs'] != 'newbie' ) {
@@ -220,6 +224,7 @@ class SpecialContributions extends SpecialPage {
                }
                $nt = $userObj->getUserPage();
                $talk = $userObj->getTalkPage();
+               $links = '';
                if ( $talk ) {
                        $tools = $this->getUserLinks( $nt, $talk, $userObj );
                        $links = $this->getLanguage()->pipeList( $tools );
@@ -254,7 +259,7 @@ class SpecialContributions extends SpecialPage {
                // @todo Should this be removed at some point?
                $oldMsg = $this->msg( 'contribsub' );
                if ( $oldMsg->exists() ) {
-                       $linksWithParentheses = $this->msg( 'parenteses' )->rawParams( $links )->escape();
+                       $linksWithParentheses = $this->msg( 'parentheses' )->rawParams( $links )->escaped();
                        return $oldMsg->rawParams( "$user $linksWithParentheses" );
                } else {
                        return $this->msg( 'contribsub2' )->rawParams( $user, $links );
@@ -444,7 +449,15 @@ class SpecialContributions extends SpecialPage {
                                )
                        ) .
                        Xml::tags( 'td', null,
-                               Xml::namespaceSelector( $this->opts['namespace'], '' ) . ' ' .
+                               Html::namespaceSelector( array(
+                                       'selected' => $this->opts['namespace'],
+                                       'all'      => '',
+                               ), array(
+                                       'name'  => 'namespace',
+                                       'id'    => 'namespace',
+                                       'class' => 'namespaceselector',
+                               ) ) .
+                               ' ' .
                                Html::rawElement( 'span', array( 'style' => 'white-space: nowrap' ),
                                        Xml::checkLabel(
                                                $this->msg( 'invert' )->text(),
@@ -537,6 +550,11 @@ class ContribsPager extends ReverseChronologicalPager {
        var $namespace = '', $mDb;
        var $preventClickjacking = false;
 
+       /**
+        * @var array
+        */
+       protected $mParentLens;
+
        function __construct( IContextSource $context, array $options ) {
                parent::__construct( $context );
 
@@ -627,13 +645,14 @@ class ContribsPager extends ReverseChronologicalPager {
                        # @todo FIXME: Other groups may have 'bot' rights
                        $join_conds['user_groups'] = array( 'LEFT JOIN', "ug_user = rev_user AND ug_group = 'bot'" );
                } else {
-                       if ( IP::isIPAddress( $this->target ) ) {
+                       $uid = User::idFromName( $this->target );
+                       if ( $uid ) {
+                               $condition['rev_user'] = $uid;
+                               $index = 'user_timestamp';
+                       } else {
                                $condition['rev_user_text'] = $this->target;
                                $index = 'usertext_timestamp';
-                       } else {
-                               $condition['rev_user'] = User::idFromName( $this->target );
-                               $index = 'user_timestamp';
-                       }
+                       } 
                }
                if ( $this->deletedOnly ) {
                        $condition[] = "rev_deleted != '0'";
@@ -700,6 +719,7 @@ class ContribsPager extends ReverseChronologicalPager {
 
        /**
         * Do a batched query to get the parent revision lengths
+        * @param $revIds array
         * @return array
         */
        private function getParentLengths( array $revIds ) {
@@ -742,6 +762,7 @@ class ContribsPager extends ReverseChronologicalPager {
         * was not written by the target user.
         *
         * @todo This would probably look a lot nicer in a table.
+        * @param $row
         * @return string
         */
        function formatRow( $row ) {
@@ -791,9 +812,16 @@ class ContribsPager extends ReverseChronologicalPager {
                        array( 'action' => 'history' )
                );
 
-               $parentLen = isset( $this->mParentLens[$row->rev_parent_id] ) ? $this->mParentLens[$row->rev_parent_id] : 0;
-               $chardiff = ' . . ' . ChangesList::showCharacterDifference(
-                               $parentLen, $row->rev_len ) . ' . . ';
+               if ( $row->rev_parent_id === null ) {
+                       // For some reason rev_parent_id isn't populated for this row.
+                       // Its rumoured this is true on wikipedia for some revisions (bug 34922).
+                       // Next best thing is to have the total number of bytes.
+                       $chardiff = ' . . ' . Linker::formatRevisionSize( $row->rev_len ) . ' . . ';
+               } else {
+                       $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 );
@@ -839,7 +867,7 @@ class ContribsPager extends ReverseChronologicalPager {
                        $del .= ' ';
                }
 
-               $diffHistLinks = $this->msg( 'parentheses' )->rawParams( $difftext . $this->messages['pipe-separator'] . $histlink )->escape();
+               $diffHistLinks = $this->msg( 'parentheses' )->rawParams( $difftext . $this->messages['pipe-separator'] . $histlink )->escaped();
                $ret = "{$del}{$d} {$diffHistLinks}{$chardiff}{$nflag}{$mflag} {$link}{$userlink} {$comment} {$topmarktext}";
 
                # Denote if username is redacted for this edit
@@ -886,6 +914,9 @@ class ContribsPager extends ReverseChronologicalPager {
                $this->preventClickjacking = true;
        }
 
+       /**
+        * @return bool
+        */
        public function getPreventClickjacking() {
                return $this->preventClickjacking;
        }