r93321 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93320‎ | r93321 | r93322 >
Date:22:28, 27 July 2011
Author:catrope
Status:ok
Tags:
Comment:
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
Modified paths:
  • /trunk/phase3/includes/Action.php (modified) (history)
  • /trunk/phase3/includes/OutputPage.php (modified) (history)
  • /trunk/phase3/includes/SpecialPage.php (modified) (history)
  • /trunk/phase3/includes/Title.php (modified) (history)
  • /trunk/phase3/includes/User.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialEmailuser.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUserlogin.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/User.php
@@ -1265,14 +1265,13 @@
12661266 }
12671267
12681268 # User/IP blocking
1269 - $block = Block::newFromTarget( $this->getName(), $ip, !$bFromSlave );
1270 - if ( $block instanceof Block ) {
 1269+ $this->mBlock = Block::newFromTarget( $this->getName(), $ip, !$bFromSlave );
 1270+ if ( $this->mBlock instanceof Block ) {
12711271 wfDebug( __METHOD__ . ": Found block.\n" );
1272 - $this->mBlock = $block;
1273 - $this->mBlockedby = $block->getByName();
1274 - $this->mBlockreason = $block->mReason;
1275 - $this->mHideName = $block->mHideName;
1276 - $this->mAllowUsertalk = !$block->prevents( 'editownusertalk' );
 1272+ $this->mBlockedby = $this->mBlock->getByName();
 1273+ $this->mBlockreason = $this->mBlock->mReason;
 1274+ $this->mHideName = $this->mBlock->mHideName;
 1275+ $this->mAllowUsertalk = !$this->mBlock->prevents( 'editownusertalk' );
12771276 if ( $this->isLoggedIn() && $wgUser->getID() == $this->getID() ) {
12781277 $this->spreadBlock();
12791278 }
Index: trunk/phase3/includes/OutputPage.php
@@ -1934,7 +1934,7 @@
19351935 * @deprecated since 1.18
19361936 */
19371937 function blockedPage() {
1938 - throw new UserBlockedError( $this->getUser()->getBlock() );
 1938+ throw new UserBlockedError( $this->getUser()->mBlock );
19391939 }
19401940
19411941 /**
Index: trunk/phase3/includes/Title.php
@@ -1565,11 +1565,39 @@
15661566 } elseif( ( $action == 'edit' || $action == 'create' ) && !$user->isBlockedFrom( $this ) ){
15671567 // Don't block the user from editing their own talk page unless they've been
15681568 // explicitly blocked from that too.
1569 - } elseif( $user->isBlocked() && $user->getBlock()->prevents( $action ) !== false ) {
1570 - $e = new UserBlockedError( $user->getBlock() );
1571 - $params = $e->params;
1572 - array_unshift( $params, $e->msg );
1573 - $errors[] = $params;
 1569+ } elseif( $user->isBlocked() && $user->mBlock->prevents( $action ) !== false ) {
 1570+ $block = $user->mBlock;
 1571+
 1572+ // This is from OutputPage::blockedPage
 1573+ // Copied at r23888 by werdna
 1574+
 1575+ $id = $user->blockedBy();
 1576+ $reason = $user->blockedFor();
 1577+ if ( $reason == '' ) {
 1578+ $reason = wfMsg( 'blockednoreason' );
 1579+ }
 1580+ $ip = wfGetIP();
 1581+
 1582+ if ( is_numeric( $id ) ) {
 1583+ $name = User::whoIs( $id );
 1584+ } else {
 1585+ $name = $id;
 1586+ }
 1587+
 1588+ $link = '[[' . $wgContLang->getNsText( NS_USER ) . ":{$name}|{$name}]]";
 1589+ $blockid = $block->getId();
 1590+ $blockExpiry = $user->mBlock->mExpiry;
 1591+ $blockTimestamp = $wgLang->timeanddate( wfTimestamp( TS_MW, $user->mBlock->mTimestamp ), true );
 1592+ if ( $blockExpiry == 'infinity' ) {
 1593+ $blockExpiry = wfMessage( 'infiniteblock' )->text();
 1594+ } else {
 1595+ $blockExpiry = $wgLang->timeanddate( wfTimestamp( TS_MW, $blockExpiry ), true );
 1596+ }
 1597+
 1598+ $intended = strval( $user->mBlock->getTarget() );
 1599+
 1600+ $errors[] = array( ( $block->mAuto ? 'autoblockedtext' : 'blockedtext' ), $link, $reason, $ip, $name,
 1601+ $blockid, $blockExpiry, $intended, $blockTimestamp );
15741602 }
15751603
15761604 return $errors;
Index: trunk/phase3/includes/specials/SpecialUserlogin.php
@@ -746,7 +746,7 @@
747747 $this->resetLoginForm( wfMsg( 'resetpass_announce' ) );
748748 break;
749749 case self::CREATE_BLOCKED:
750 - $this->userBlockedMessage( $wgUser->getBlock() );
 750+ $this->userBlockedMessage( $wgUser->mBlock );
751751 break;
752752 case self::THROTTLED:
753753 $this->mainLoginForm( wfMsg( 'login-throttled' ) );
Index: trunk/phase3/includes/specials/SpecialEmailuser.php
@@ -99,7 +99,7 @@
100100 case 'badaccess':
101101 throw new PermissionsError( 'sendemail' );
102102 case 'blockedemailuser':
103 - throw new UserBlockedError( $this->getUser()->getBlock() );
 103+ throw new UserBlockedError( $this->getUser()->mBlock );
104104 case 'actionthrottledtext':
105105 throw new ThrottledError;
106106 case 'mailnologin':
Index: trunk/phase3/includes/SpecialPage.php
@@ -825,7 +825,8 @@
826826 }
827827
828828 if ( $this->requiresUnblock() && $user->isBlocked() ) {
829 - throw new UserBlockedError( $user->getBlock() );
 829+ $block = $user->mBlock;
 830+ throw new UserBlockedError( $block );
830831 }
831832
832833 return true;
Index: trunk/phase3/includes/Action.php
@@ -198,7 +198,8 @@
199199 }
200200
201201 if ( $this->requiresUnblock() && $user->isBlocked() ) {
202 - throw new UserBlockedError( $user->getBlock() );
 202+ $block = $user->mBlock;
 203+ throw new UserBlockedError( $block );
203204 }
204205 }
205206

Follow-up revisions

RevisionCommit summaryAuthorDate
r93325Followup r93321: revert r93237 for extensions toocatrope22:34, 27 July 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r93237Follow-up r93234: use User::getBlock() accessor rather than accessing $mBlock...happy-melon19:58, 26 July 2011

Status & tagging log