From: Roan Kattouw Date: Wed, 27 Jul 2011 22:28:59 +0000 (+0000) Subject: Revert r93237 ("use User::getBlock() accessor rather than accessing $mBlock directly... X-Git-Tag: 1.31.0-rc.0~28583 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=f450e4eb8cc18e8bd22def4825b20bd793889fd3;p=lhc%2Fweb%2Fwiklou.git Revert r93237 ("use User::getBlock() accessor rather than accessing $mBlock directly ..."): breaks a test (specifically TitlePermissionTest::testUserBlock()). From what I can tell it looks like the test case is expecting the text of the infinite-block message, but got a Message object instead --- diff --git a/includes/Action.php b/includes/Action.php index 6a62fb69db..ff0ce697d0 100644 --- a/includes/Action.php +++ b/includes/Action.php @@ -198,7 +198,8 @@ abstract class Action { } if ( $this->requiresUnblock() && $user->isBlocked() ) { - throw new UserBlockedError( $user->getBlock() ); + $block = $user->mBlock; + throw new UserBlockedError( $block ); } } diff --git a/includes/OutputPage.php b/includes/OutputPage.php index dcd0675607..067158b330 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -1934,7 +1934,7 @@ class OutputPage { * @deprecated since 1.18 */ function blockedPage() { - throw new UserBlockedError( $this->getUser()->getBlock() ); + throw new UserBlockedError( $this->getUser()->mBlock ); } /** diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index 9984ac0592..fbcd25e88e 100644 --- a/includes/SpecialPage.php +++ b/includes/SpecialPage.php @@ -825,7 +825,8 @@ abstract class FormSpecialPage extends SpecialPage { } if ( $this->requiresUnblock() && $user->isBlocked() ) { - throw new UserBlockedError( $user->getBlock() ); + $block = $user->mBlock; + throw new UserBlockedError( $block ); } return true; diff --git a/includes/Title.php b/includes/Title.php index 76519d0a33..a774404f28 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -1565,11 +1565,39 @@ 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->getBlock()->prevents( $action ) !== false ) { - $e = new UserBlockedError( $user->getBlock() ); - $params = $e->params; - array_unshift( $params, $e->msg ); - $errors[] = $params; + } 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 ); } return $errors; diff --git a/includes/User.php b/includes/User.php index 4d9b4c74c0..a160e93a0d 100644 --- a/includes/User.php +++ b/includes/User.php @@ -1265,14 +1265,13 @@ class User { } # User/IP blocking - $block = Block::newFromTarget( $this->getName(), $ip, !$bFromSlave ); - if ( $block instanceof Block ) { + $this->mBlock = Block::newFromTarget( $this->getName(), $ip, !$bFromSlave ); + if ( $this->mBlock instanceof Block ) { wfDebug( __METHOD__ . ": Found block.\n" ); - $this->mBlock = $block; - $this->mBlockedby = $block->getByName(); - $this->mBlockreason = $block->mReason; - $this->mHideName = $block->mHideName; - $this->mAllowUsertalk = !$block->prevents( 'editownusertalk' ); + $this->mBlockedby = $this->mBlock->getByName(); + $this->mBlockreason = $this->mBlock->mReason; + $this->mHideName = $this->mBlock->mHideName; + $this->mAllowUsertalk = !$this->mBlock->prevents( 'editownusertalk' ); if ( $this->isLoggedIn() && $wgUser->getID() == $this->getID() ) { $this->spreadBlock(); } diff --git a/includes/specials/SpecialEmailuser.php b/includes/specials/SpecialEmailuser.php index 509f7fc680..52501e4948 100644 --- a/includes/specials/SpecialEmailuser.php +++ b/includes/specials/SpecialEmailuser.php @@ -99,7 +99,7 @@ class SpecialEmailUser extends UnlistedSpecialPage { case 'badaccess': throw new PermissionsError( 'sendemail' ); case 'blockedemailuser': - throw new UserBlockedError( $this->getUser()->getBlock() ); + throw new UserBlockedError( $this->getUser()->mBlock ); case 'actionthrottledtext': throw new ThrottledError; case 'mailnologin': diff --git a/includes/specials/SpecialUserlogin.php b/includes/specials/SpecialUserlogin.php index bed5a14f1a..a933041270 100644 --- a/includes/specials/SpecialUserlogin.php +++ b/includes/specials/SpecialUserlogin.php @@ -746,7 +746,7 @@ class LoginForm extends SpecialPage { $this->resetLoginForm( wfMsg( 'resetpass_announce' ) ); break; case self::CREATE_BLOCKED: - $this->userBlockedMessage( $wgUser->getBlock() ); + $this->userBlockedMessage( $wgUser->mBlock ); break; case self::THROTTLED: $this->mainLoginForm( wfMsg( 'login-throttled' ) );