(bug 37330) Fix wrong block being displayed due to autoblock in place.
[lhc/web/wiklou.git] / includes / specials / SpecialContributions.php
index 2a46573..62b34ad 100644 (file)
@@ -54,6 +54,9 @@ class SpecialContributions extends SpecialPage {
                if ( $request->getVal( 'contribs' ) == 'newbie' ) {
                        $target = 'newbies';
                        $this->opts['contribs'] = 'newbie';
+               } elseif ( $par === 'newbies' ) { // b/c for WMF
+                       $target = 'newbies';
+                       $this->opts['contribs'] = 'newbie';
                } else {
                        $this->opts['contribs'] = 'user';
                }
@@ -71,12 +74,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' ) {
@@ -185,18 +192,20 @@ class SpecialContributions extends SpecialPage {
                        }
                        $out->preventClickjacking( $pager->getPreventClickjacking() );
 
+
                        # Show the appropriate "footer" message - WHOIS tools, etc.
-                       if ( $this->opts['contribs'] != 'newbie' ) {
+                       if ( $this->opts['contribs'] == 'newbie' ) {
+                               $message = 'sp-contributions-footer-newbies';
+                       } elseif( IP::isIPAddress( $target ) ) {
+                               $message = 'sp-contributions-footer-anon';
+                       } elseif( $userObj->isAnon() ) {
+                               // No message for non-existing users
+                               $message = '';
+                       } else {
                                $message = 'sp-contributions-footer';
-                               if ( IP::isIPAddress( $target ) ) {
-                                       $message = 'sp-contributions-footer-anon';
-                               } else {
-                                       if ( $userObj->isAnon() ) {
-                                               // No message for non-existing users
-                                               return;
-                                       }
-                               }
+                       }
 
+                       if( $message ) {
                                if ( !$this->msg( $message, $target )->isDisabled() ) {
                                        $out->wrapWikiMsg(
                                                "<div class='mw-contributions-footer'>\n$1\n</div>",
@@ -220,12 +229,15 @@ class SpecialContributions extends SpecialPage {
                }
                $nt = $userObj->getUserPage();
                $talk = $userObj->getTalkPage();
+               $links = '';
                if ( $talk ) {
                        $tools = $this->getUserLinks( $nt, $talk, $userObj );
                        $links = $this->getLanguage()->pipeList( $tools );
 
                        // Show a note if the user is blocked and display the last block log entry.
-                       if ( $userObj->isBlocked() ) {
+                       // Do not expose the autoblocks, since that may lead to a leak of accounts' IPs,
+                       // and also this will display a totally irrelevant log entry as a current block.
+                       if ( $userObj->isBlocked() && $userObj->getBlock()->getType() != Block::TYPE_AUTO ) {
                                $out = $this->getOutput(); // showLogExtract() wants first parameter by reference
                                LogEventsList::showLogExtract(
                                        $out,
@@ -326,7 +338,7 @@ class SpecialContributions extends SpecialPage {
                # Add a link to change user rights for privileged users
                $userrightsPage = new UserrightsPage();
                $userrightsPage->setContext( $this->getContext() );
-               if ( $id !== null && $userrightsPage->userCanChangeRights( $target ) ) {
+               if ( $userrightsPage->userCanChangeRights( $target ) ) {
                        $tools[] = Linker::linkKnown(
                                SpecialPage::getTitleFor( 'Userrights', $username ),
                                $this->msg( 'sp-contributions-userrights' )->escaped()
@@ -447,7 +459,6 @@ class SpecialContributions extends SpecialPage {
                                Html::namespaceSelector( array(
                                        'selected' => $this->opts['namespace'],
                                        'all'      => '',
-                                       'label'    => null,
                                ), array(
                                        'name'  => 'namespace',
                                        'id'    => 'namespace',
@@ -546,6 +557,11 @@ class ContribsPager extends ReverseChronologicalPager {
        var $namespace = '', $mDb;
        var $preventClickjacking = false;
 
+       /**
+        * @var array
+        */
+       protected $mParentLens;
+
        function __construct( IContextSource $context, array $options ) {
                parent::__construct( $context );
 
@@ -643,7 +659,7 @@ class ContribsPager extends ReverseChronologicalPager {
                        } else {
                                $condition['rev_user_text'] = $this->target;
                                $index = 'usertext_timestamp';
-                       } 
+                       }
                }
                if ( $this->deletedOnly ) {
                        $condition[] = "rev_deleted != '0'";
@@ -710,6 +726,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 ) {
@@ -752,6 +769,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 ) {
@@ -903,6 +921,9 @@ class ContribsPager extends ReverseChronologicalPager {
                $this->preventClickjacking = true;
        }
 
+       /**
+        * @return bool
+        */
        public function getPreventClickjacking() {
                return $this->preventClickjacking;
        }