Revert "Remove is_numeric check from Title::checkUserBlock"
authorHashar <hashar@free.fr>
Tue, 9 Apr 2013 08:20:12 +0000 (08:20 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 9 Apr 2013 08:20:12 +0000 (08:20 +0000)
Breaks unit testing (see bug 47031). The commit managed to land in
the branch because of a bug in Jenkins (bug 46723).

This reverts commit 8cc0b601aa2db6db09ac0e4d70847293d75875aa

Change-Id: I4b3fadccaae9c35964a0c47d63b22c4f35148a24

RELEASE-NOTES-1.22
includes/Block.php
includes/Exception.php
includes/Title.php

index 00198ab..5c0098d 100644 (file)
@@ -14,7 +14,6 @@ production.
 === New features in 1.22 ===
 
 === Bug fixes in 1.22 ===
-* (bug 46768) Usernames of blocking users now display correctly, even if numeric.
 
 === API changes in 1.22 ===
 
index 1a0949c..4da0f8f 100644 (file)
@@ -1384,43 +1384,4 @@ class Block {
        public function setBlocker( $user ) {
                $this->blocker = $user;
        }
-
-       /**
-        * Get the key and parameters for the corresponding error message.
-        *
-        * @since 1.22
-        * @param IContextSource $context
-        * @return array
-        */
-       public function getPermissionsError( IContextSource $context ) {
-               $blocker = $this->getBlocker();
-               if ( $blocker instanceof User ) { // local user
-                       $blockerUserpage = $blocker->getUserPage();
-                       $link = "[[{$blockerUserpage->getPrefixedText()}|{$blockerUserpage->getText()}]]";
-               } else { // foreign user
-                       $link = $blocker;
-               }
-
-               $reason = $this->mReason;
-               if ( $reason == '' ) {
-                       $reason = $context->msg( 'blockednoreason' )->text();
-               }
-
-               /* $ip returns who *is* being blocked, $intended contains who was meant to be blocked.
-                * This could be a username, an IP range, or a single IP. */
-               $intended = $this->getTarget();
-
-               $lang = $context->getLanguage();
-               return array(
-                       $this->mAuto ? 'autoblockedtext' : 'blockedtext',
-                       $link,
-                       $reason,
-                       $context->getRequest()->getIP(),
-                       $this->getByName(),
-                       $this->getId(),
-                       $lang->formatExpiry( $this->mExpiry ),
-                       $intended,
-                       $lang->timeanddate( wfTimestamp( TS_MW, $this->mTimestamp ), true ),
-               );
-       }
 }
index 855eb09..21952bb 100644 (file)
@@ -467,9 +467,39 @@ class ThrottledError extends ErrorPageError {
  */
 class UserBlockedError extends ErrorPageError {
        public function __construct( Block $block ) {
-               // @todo FIXME: Implement a more proper way to get context here.
-               $params = $block->getPermissionsError( RequestContext::getMain() );
-               parent::__construct( 'blockedtitle', array_shift( $params ), $params );
+               global $wgLang, $wgRequest;
+
+               $blocker = $block->getBlocker();
+               if ( $blocker instanceof User ) { // local user
+                       $blockerUserpage = $block->getBlocker()->getUserPage();
+                       $link = "[[{$blockerUserpage->getPrefixedText()}|{$blockerUserpage->getText()}]]";
+               } else { // foreign user
+                       $link = $blocker;
+               }
+
+               $reason = $block->mReason;
+               if( $reason == '' ) {
+                       $reason = wfMessage( 'blockednoreason' )->text();
+               }
+
+               /* $ip returns who *is* being blocked, $intended contains who was meant to be blocked.
+                * This could be a username, an IP range, or a single IP. */
+               $intended = $block->getTarget();
+
+               parent::__construct(
+                       'blockedtitle',
+                       $block->mAuto ? 'autoblockedtext' : 'blockedtext',
+                       array(
+                               $link,
+                               $reason,
+                               $wgRequest->getIP(),
+                               $block->getByName(),
+                               $block->getId(),
+                               $wgLang->formatExpiry( $block->mExpiry ),
+                               $intended,
+                               $wgLang->timeanddate( wfTimestamp( TS_MW, $block->mTimestamp ), true )
+                       )
+               );
        }
 }
 
index 6ac17d6..aa8fb93 100644 (file)
@@ -2049,8 +2049,38 @@ class Title {
                        // Don't block the user from editing their own talk page unless they've been
                        // explicitly blocked from that too.
                } elseif( $user->isBlocked() && $user->mBlock->prevents( $action ) !== false ) {
-                       // @todo FIXME: Pass the relevant context into this function.
-                       $errors[] = $user->getBlock()->getPermissionsError( RequestContext::getMain() );
+                       $block = $user->getBlock();
+
+                       // This is from OutputPage::blockedPage
+                       // Copied at r23888 by werdna
+
+                       $id = $user->blockedBy();
+                       $reason = $user->blockedFor();
+                       if ( $reason == '' ) {
+                               $reason = wfMessage( 'blockednoreason' )->text();
+                       }
+                       $ip = $user->getRequest()->getIP();
+
+                       if ( is_numeric( $id ) ) {
+                               $name = User::whoIs( $id );
+                       } else {
+                               $name = $id;
+                       }
+
+                       $link = '[[' . $wgContLang->getNsText( NS_USER ) . ":{$name}|{$name}]]";
+                       $blockid = $block->getId();
+                       $blockExpiry = $block->getExpiry();
+                       $blockTimestamp = $wgLang->timeanddate( wfTimestamp( TS_MW, $block->mTimestamp ), true );
+                       if ( $blockExpiry == 'infinity' ) {
+                               $blockExpiry = wfMessage( 'infiniteblock' )->text();
+                       } else {
+                               $blockExpiry = $wgLang->timeanddate( wfTimestamp( TS_MW, $blockExpiry ), true );
+                       }
+
+                       $intended = strval( $block->getTarget() );
+
+                       $errors[] = array( ( $block->mAuto ? 'autoblockedtext' : 'blockedtext' ), $link, $reason, $ip, $name,
+                               $blockid, $blockExpiry, $intended, $blockTimestamp );
                }
 
                return $errors;