Follow-up r93234: use User::getBlock() accessor rather than accessing $mBlock directl...
authorHappy-melon <happy-melon@users.mediawiki.org>
Tue, 26 Jul 2011 19:58:26 +0000 (19:58 +0000)
committerHappy-melon <happy-melon@users.mediawiki.org>
Tue, 26 Jul 2011 19:58:26 +0000 (19:58 +0000)
includes/Action.php
includes/OutputPage.php
includes/SpecialPage.php
includes/Title.php
includes/User.php
includes/specials/SpecialEmailuser.php
includes/specials/SpecialUserlogin.php

index ff0ce69..6a62fb6 100644 (file)
@@ -198,8 +198,7 @@ abstract class Action {
                }
 
                if ( $this->requiresUnblock() && $user->isBlocked() ) {
-                       $block = $user->mBlock;
-                       throw new UserBlockedError( $block );
+                       throw new UserBlockedError( $user->getBlock() );
                }
        }
 
index 9db347a..fb7f67e 100644 (file)
@@ -1934,7 +1934,7 @@ class OutputPage {
         * @deprecated since 1.18
         */
        function blockedPage() {
-               throw new UserBlockedError( $this->getUser()->mBlock );
+               throw new UserBlockedError( $this->getUser()->getBlock() );
        }
 
        /**
index a91b587..adb408e 100644 (file)
@@ -825,8 +825,7 @@ abstract class FormSpecialPage extends SpecialPage {
                }
 
                if ( $this->requiresUnblock() && $user->isBlocked() ) {
-                       $block = $user->mBlock;
-                       throw new UserBlockedError( $block );
+                       throw new UserBlockedError( $user->getBlock() );
                }
 
                return true;
index a774404..76519d0 100644 (file)
@@ -1565,39 +1565,11 @@ class Title {
                } elseif( ( $action == 'edit' || $action == 'create' ) && !$user->isBlockedFrom( $this ) ){
                        // 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 ) {
-                       $block = $user->mBlock;
-
-                       // This is from OutputPage::blockedPage
-                       // Copied at r23888 by werdna
-
-                       $id = $user->blockedBy();
-                       $reason = $user->blockedFor();
-                       if ( $reason == '' ) {
-                               $reason = wfMsg( 'blockednoreason' );
-                       }
-                       $ip = wfGetIP();
-
-                       if ( is_numeric( $id ) ) {
-                               $name = User::whoIs( $id );
-                       } else {
-                               $name = $id;
-                       }
-
-                       $link = '[[' . $wgContLang->getNsText( NS_USER ) . ":{$name}|{$name}]]";
-                       $blockid = $block->getId();
-                       $blockExpiry = $user->mBlock->mExpiry;
-                       $blockTimestamp = $wgLang->timeanddate( wfTimestamp( TS_MW, $user->mBlock->mTimestamp ), true );
-                       if ( $blockExpiry == 'infinity' ) {
-                               $blockExpiry = wfMessage( 'infiniteblock' )->text();
-                       } else {
-                               $blockExpiry = $wgLang->timeanddate( wfTimestamp( TS_MW, $blockExpiry ), true );
-                       }
-
-                       $intended = strval( $user->mBlock->getTarget() );
-
-                       $errors[] = array( ( $block->mAuto ? 'autoblockedtext' : 'blockedtext' ), $link, $reason, $ip, $name,
-                               $blockid, $blockExpiry, $intended, $blockTimestamp );
+               } elseif( $user->isBlocked() && $user->getBlock()->prevents( $action ) !== false ) {
+                       $e = new UserBlockedError( $user->getBlock() );
+                       $params = $e->params;
+                       array_unshift( $params, $e->msg );
+                       $errors[] = $params;
                }
 
                return $errors;
index a160e93..4d9b4c7 100644 (file)
@@ -1265,13 +1265,14 @@ class User {
                }
 
                # User/IP blocking
-               $this->mBlock = Block::newFromTarget( $this->getName(), $ip, !$bFromSlave );
-               if ( $this->mBlock instanceof Block ) {
+               $block = Block::newFromTarget( $this->getName(), $ip, !$bFromSlave );
+               if ( $block instanceof Block ) {
                        wfDebug( __METHOD__ . ": Found block.\n" );
-                       $this->mBlockedby = $this->mBlock->getByName();
-                       $this->mBlockreason = $this->mBlock->mReason;
-                       $this->mHideName = $this->mBlock->mHideName;
-                       $this->mAllowUsertalk = !$this->mBlock->prevents( 'editownusertalk' );
+                       $this->mBlock = $block;
+                       $this->mBlockedby = $block->getByName();
+                       $this->mBlockreason = $block->mReason;
+                       $this->mHideName = $block->mHideName;
+                       $this->mAllowUsertalk = !$block->prevents( 'editownusertalk' );
                        if ( $this->isLoggedIn() && $wgUser->getID() == $this->getID() ) {
                                $this->spreadBlock();
                        }
index 52501e4..509f7fc 100644 (file)
@@ -99,7 +99,7 @@ class SpecialEmailUser extends UnlistedSpecialPage {
                        case 'badaccess':
                                throw new PermissionsError( 'sendemail' );
                        case 'blockedemailuser':
-                               throw new UserBlockedError( $this->getUser()->mBlock );
+                               throw new UserBlockedError( $this->getUser()->getBlock() );
                        case 'actionthrottledtext':
                                throw new ThrottledError;
                        case 'mailnologin':
index a933041..bed5a14 100644 (file)
@@ -746,7 +746,7 @@ class LoginForm extends SpecialPage {
                                $this->resetLoginForm( wfMsg( 'resetpass_announce' ) );
                                break;
                        case self::CREATE_BLOCKED:
-                               $this->userBlockedMessage( $wgUser->mBlock );
+                               $this->userBlockedMessage( $wgUser->getBlock() );
                                break;
                        case self::THROTTLED:
                                $this->mainLoginForm( wfMsg( 'login-throttled' ) );