Remove reliance on Block properties being public
authorThalia <thalia.e.chan@googlemail.com>
Fri, 22 Mar 2019 15:16:40 +0000 (15:16 +0000)
committerThalia <thalia.e.chan@googlemail.com>
Fri, 22 Mar 2019 21:17:22 +0000 (21:17 +0000)
Use getters and setters for $mReason, $mTimestamp, $mExpiry and
$mHideName; use Block::getType to check if a block is an autoblock
instead of checking $mAuto; no change needed for $mParentBlockId,
which is not accessed externally.

Change-Id: I767ed44ce4c2e21f53962d75fb86891add2282f6

13 files changed:
includes/Block.php
includes/api/ApiBlock.php
includes/api/ApiQueryUserInfo.php
includes/auth/AuthManager.php
includes/auth/CheckBlocksSecondaryAuthenticationProvider.php
includes/specials/SpecialBlock.php
includes/specials/SpecialUnblock.php
includes/user/User.php
tests/phpunit/includes/BlockTest.php
tests/phpunit/includes/TitlePermissionTest.php
tests/phpunit/includes/api/ApiBlockTest.php
tests/phpunit/includes/specials/SpecialBlockTest.php
tests/phpunit/includes/user/UserTest.php

index 0693650..7e32f7e 100644 (file)
@@ -165,13 +165,13 @@ class Block {
                        $this->setBlocker( $options['byText'] );
                }
 
-               $this->mReason = $options['reason'];
+               $this->setReason( $options['reason'] );
                $this->mTimestamp = wfTimestamp( TS_MW, $options['timestamp'] );
-               $this->mExpiry = wfGetDB( DB_REPLICA )->decodeExpiry( $options['expiry'] );
+               $this->setExpiry( wfGetDB( DB_REPLICA )->decodeExpiry( $options['expiry'] ) );
 
                # Boolean settings
                $this->mAuto = (bool)$options['auto'];
-               $this->mHideName = (bool)$options['hideName'];
+               $this->setHideName( (bool)$options['hideName'] );
                $this->isHardblock( !$options['anonOnly'] );
                $this->isAutoblocking( (bool)$options['enableAutoblock'] );
                $this->isSitewide( (bool)$options['sitewide'] );
@@ -296,12 +296,12 @@ class Block {
                        && $this->mAuto == $block->mAuto
                        && $this->isHardblock() == $block->isHardblock()
                        && $this->isCreateAccountBlocked() == $block->isCreateAccountBlocked()
-                       && $this->mExpiry == $block->mExpiry
+                       && $this->getExpiry() == $block->getExpiry()
                        && $this->isAutoblocking() == $block->isAutoblocking()
-                       && $this->mHideName == $block->mHideName
+                       && $this->getHideName() == $block->getHideName()
                        && $this->isEmailBlocked() == $block->isEmailBlocked()
                        && $this->isUsertalkEditAllowed() == $block->isUsertalkEditAllowed()
-                       && $this->mReason == $block->mReason
+                       && $this->getReason() == $block->getReason()
                        && $this->isSitewide() == $block->isSitewide()
                        // Block::getRestrictions() may perform a database query, so keep it at
                        // the end.
@@ -473,16 +473,18 @@ class Block {
 
                $this->mTimestamp = wfTimestamp( TS_MW, $row->ipb_timestamp );
                $this->mAuto = $row->ipb_auto;
-               $this->mHideName = $row->ipb_deleted;
+               $this->setHideName( $row->ipb_deleted );
                $this->mId = (int)$row->ipb_id;
                $this->mParentBlockId = $row->ipb_parent_block_id;
 
                // I wish I didn't have to do this
                $db = wfGetDB( DB_REPLICA );
-               $this->mExpiry = $db->decodeExpiry( $row->ipb_expiry );
-               $this->mReason = CommentStore::getStore()
+               $this->setExpiry( $db->decodeExpiry( $row->ipb_expiry ) );
+               $this->setReason(
+                       CommentStore::getStore()
                        // Legacy because $row may have come from self::selectFields()
-                       ->getCommentLegacy( $db, 'ipb_reason', $row )->text;
+                       ->getCommentLegacy( $db, 'ipb_reason', $row )->text
+               );
 
                $this->isHardblock( !$row->ipb_anon_only );
                $this->isAutoblocking( $row->ipb_enable_autoblock );
@@ -679,7 +681,7 @@ class Block {
         * @return array
         */
        protected function getDatabaseArray( IDatabase $dbw ) {
-               $expiry = $dbw->encodeExpiry( $this->mExpiry );
+               $expiry = $dbw->encodeExpiry( $this->getExpiry() );
 
                if ( $this->forcedTargetID ) {
                        $uid = $this->forcedTargetID;
@@ -690,7 +692,7 @@ class Block {
                $a = [
                        'ipb_address'          => (string)$this->target,
                        'ipb_user'             => $uid,
-                       'ipb_timestamp'        => $dbw->timestamp( $this->mTimestamp ),
+                       'ipb_timestamp'        => $dbw->timestamp( $this->getTimestamp() ),
                        'ipb_auto'             => $this->mAuto,
                        'ipb_anon_only'        => !$this->isHardblock(),
                        'ipb_create_account'   => $this->isCreateAccountBlocked(),
@@ -698,12 +700,12 @@ class Block {
                        'ipb_expiry'           => $expiry,
                        'ipb_range_start'      => $this->getRangeStart(),
                        'ipb_range_end'        => $this->getRangeEnd(),
-                       'ipb_deleted'          => intval( $this->mHideName ), // typecast required for SQLite
+                       'ipb_deleted'          => intval( $this->getHideName() ), // typecast required for SQLite
                        'ipb_block_email'      => $this->isEmailBlocked(),
                        'ipb_allow_usertalk'   => $this->isUsertalkEditAllowed(),
                        'ipb_parent_block_id'  => $this->mParentBlockId,
                        'ipb_sitewide'         => $this->isSitewide(),
-               ] + CommentStore::getStore()->insert( $dbw, 'ipb_reason', $this->mReason )
+               ] + CommentStore::getStore()->insert( $dbw, 'ipb_reason', $this->getReason() )
                        + ActorMigration::newMigration()->getInsertValues( $dbw, 'ipb_by', $this->getBlocker() );
 
                return $a;
@@ -716,10 +718,10 @@ class Block {
        protected function getAutoblockUpdateArray( IDatabase $dbw ) {
                return [
                        'ipb_create_account'   => $this->isCreateAccountBlocked(),
-                       'ipb_deleted'          => (int)$this->mHideName, // typecast required for SQLite
+                       'ipb_deleted'          => (int)$this->getHideName(), // typecast required for SQLite
                        'ipb_allow_usertalk'   => $this->isUsertalkEditAllowed(),
                        'ipb_sitewide'         => $this->isSitewide(),
-               ] + CommentStore::getStore()->insert( $dbw, 'ipb_reason', $this->mReason )
+               ] + CommentStore::getStore()->insert( $dbw, 'ipb_reason', $this->getReason() )
                        + ActorMigration::newMigration()->getInsertValues( $dbw, 'ipb_by', $this->getBlocker() );
        }
 
@@ -883,7 +885,7 @@ class Block {
                        # Check if the block is an autoblock and would exceed the user block
                        # if renewed. If so, do nothing, otherwise prolong the block time...
                        if ( $ipblock->mAuto && // @todo Why not compare $ipblock->mExpiry?
-                               $this->mExpiry > self::getAutoblockExpiry( $ipblock->mTimestamp )
+                               $this->getExpiry() > self::getAutoblockExpiry( $ipblock->getTimestamp() )
                        ) {
                                # Reset block timestamp to now and its expiry to
                                # $wgAutoblockExpiry in the future
@@ -897,26 +899,28 @@ class Block {
                wfDebug( "Autoblocking {$this->getTarget()}@" . $autoblockIP . "\n" );
                $autoblock->setTarget( $autoblockIP );
                $autoblock->setBlocker( $this->getBlocker() );
-               $autoblock->mReason = wfMessage( 'autoblocker', $this->getTarget(), $this->mReason )
-                       ->inContentLanguage()->plain();
+               $autoblock->setReason(
+                       wfMessage( 'autoblocker', $this->getTarget(), $this->getReason() )
+                               ->inContentLanguage()->plain()
+               );
                $timestamp = wfTimestampNow();
                $autoblock->mTimestamp = $timestamp;
                $autoblock->mAuto = 1;
                $autoblock->isCreateAccountBlocked( $this->isCreateAccountBlocked() );
                # Continue suppressing the name if needed
-               $autoblock->mHideName = $this->mHideName;
+               $autoblock->setHideName( $this->getHideName() );
                $autoblock->isUsertalkEditAllowed( $this->isUsertalkEditAllowed() );
                $autoblock->mParentBlockId = $this->mId;
                $autoblock->isSitewide( $this->isSitewide() );
                $autoblock->setRestrictions( $this->getRestrictions() );
 
-               if ( $this->mExpiry == 'infinity' ) {
+               if ( $this->getExpiry() == 'infinity' ) {
                        # Original block was indefinite, start an autoblock now
-                       $autoblock->mExpiry = self::getAutoblockExpiry( $timestamp );
+                       $autoblock->setExpiry( self::getAutoblockExpiry( $timestamp ) );
                } else {
                        # If the user is already blocked with an expiry date, we don't
                        # want to pile on top of that.
-                       $autoblock->mExpiry = min( $this->mExpiry, self::getAutoblockExpiry( $timestamp ) );
+                       $autoblock->setExpiry( min( $this->getExpiry(), self::getAutoblockExpiry( $timestamp ) ) );
                }
 
                # Insert the block...
@@ -951,10 +955,10 @@ class Block {
                $timestamp = wfTimestampNow();
                wfDebug( "Block::isExpired() checking current " . $timestamp . " vs $this->mExpiry\n" );
 
-               if ( !$this->mExpiry ) {
+               if ( !$this->getExpiry() ) {
                        return false;
                } else {
-                       return $timestamp > $this->mExpiry;
+                       return $timestamp > $this->getExpiry();
                }
        }
 
@@ -972,13 +976,13 @@ class Block {
        public function updateTimestamp() {
                if ( $this->mAuto ) {
                        $this->mTimestamp = wfTimestamp();
-                       $this->mExpiry = self::getAutoblockExpiry( $this->mTimestamp );
+                       $this->setExpiry( self::getAutoblockExpiry( $this->getTimestamp() ) );
 
                        $dbw = wfGetDB( DB_MASTER );
                        $dbw->update( 'ipblocks',
                                [ /* SET */
-                                       'ipb_timestamp' => $dbw->timestamp( $this->mTimestamp ),
-                                       'ipb_expiry' => $dbw->timestamp( $this->mExpiry ),
+                                       'ipb_timestamp' => $dbw->timestamp( $this->getTimestamp() ),
+                                       'ipb_expiry' => $dbw->timestamp( $this->getExpiry() ),
                                ],
                                [ /* WHERE */
                                        'ipb_id' => $this->getId(),
@@ -1074,6 +1078,46 @@ class Block {
                return $this;
        }
 
+       /**
+        * Get the reason given for creating the block
+        *
+        * @since 1.33
+        * @return string
+        */
+       public function getReason() {
+               return $this->mReason;
+       }
+
+       /**
+        * Set the reason for creating the block
+        *
+        * @since 1.33
+        * @param string $reason
+        */
+       public function setReason( $reason ) {
+               $this->mReason = $reason;
+       }
+
+       /**
+        * Get whether the block hides the target's username
+        *
+        * @since 1.33
+        * @return bool The block hides the username
+        */
+       public function getHideName() {
+               return $this->mHideName;
+       }
+
+       /**
+        * Set whether ths block hides the target's username
+        *
+        * @since 1.33
+        * @param bool $hideName The block hides the username
+        */
+       public function setHideName( $hideName ) {
+               $this->mHideName = $hideName;
+       }
+
        /**
         * Get the system block type, if any
         * @since 1.29
@@ -1660,14 +1704,45 @@ class Block {
        }
 
        /**
-        * @since 1.19
+        * Get the block expiry time
         *
-        * @return mixed|string
+        * @since 1.19
+        * @return string
         */
        public function getExpiry() {
                return $this->mExpiry;
        }
 
+       /**
+        * Set the block expiry time
+        *
+        * @since 1.33
+        * @param string $expiry
+        */
+       public function setExpiry( $expiry ) {
+               $this->mExpiry = $expiry;
+       }
+
+       /**
+        * Get the timestamp indicating when the block was created
+        *
+        * @since 1.33
+        * @return string
+        */
+       public function getTimestamp() {
+               return $this->mTimestamp;
+       }
+
+       /**
+        * Set the timestamp indicating when the block was created
+        *
+        * @since 1.33
+        * @param string $timestamp
+        */
+       public function setTimestamp( $timestamp ) {
+               $this->mTimestamp = $timestamp;
+       }
+
        /**
         * Set the target for this block, and update $this->type accordingly
         * @param mixed $target
@@ -1830,7 +1905,7 @@ class Block {
                        $link = $blocker;
                }
 
-               $reason = $this->mReason;
+               $reason = $this->getReason();
                if ( $reason == '' ) {
                        $reason = $context->msg( 'blockednoreason' )->text();
                }
@@ -1847,9 +1922,9 @@ class Block {
                        $context->getRequest()->getIP(),
                        $this->getByName(),
                        $systemBlockType ?? $this->getId(),
-                       $lang->formatExpiry( $this->mExpiry ),
+                       $lang->formatExpiry( $this->getExpiry() ),
                        (string)$intended,
-                       $lang->userTimeAndDate( $this->mTimestamp, $context->getUser() ),
+                       $lang->userTimeAndDate( $this->getTimestamp(), $context->getUser() ),
                ];
        }
 
index 14177ed..673fc6b 100644 (file)
@@ -135,7 +135,7 @@ class ApiBlock extends ApiBase {
 
                $block = Block::newFromTarget( $target, null, true );
                if ( $block instanceof Block ) {
-                       $res['expiry'] = ApiResult::formatExpiry( $block->mExpiry, 'infinite' );
+                       $res['expiry'] = ApiResult::formatExpiry( $block->getExpiry(), 'infinite' );
                        $res['id'] = $block->getId();
                } else {
                        # should be unreachable
index a38d877..f594347 100644 (file)
@@ -67,8 +67,8 @@ class ApiQueryUserInfo extends ApiQueryBase {
                $vals['blockid'] = $block->getId();
                $vals['blockedby'] = $block->getByName();
                $vals['blockedbyid'] = $block->getBy();
-               $vals['blockreason'] = $block->mReason;
-               $vals['blockedtimestamp'] = wfTimestamp( TS_ISO_8601, $block->mTimestamp );
+               $vals['blockreason'] = $block->getReason();
+               $vals['blockedtimestamp'] = wfTimestamp( TS_ISO_8601, $block->getTimestamp() );
                $vals['blockexpiry'] = ApiResult::formatExpiry( $block->getExpiry(), 'infinite' );
                $vals['blockpartial'] = !$block->isSitewide();
                if ( $block->getSystemBlockType() !== null ) {
index 946decf..0c6218e 100644 (file)
@@ -1006,7 +1006,7 @@ class AuthManager implements LoggerAwareInterface {
                if ( $block ) {
                        $errorParams = [
                                $block->getTarget(),
-                               $block->mReason ?: wfMessage( 'blockednoreason' )->text(),
+                               $block->getReason() ?: wfMessage( 'blockednoreason' )->text(),
                                $block->getByName()
                        ];
 
index 7488fba..10925b5 100644 (file)
@@ -77,8 +77,8 @@ class CheckBlocksSecondaryAuthenticationProvider extends AbstractSecondaryAuthen
        public function testUserForCreation( $user, $autocreate, array $options = [] ) {
                $block = $user->isBlockedFromCreateAccount();
                if ( $block ) {
-                       if ( $block->mReason ) {
-                               $reason = $block->mReason;
+                       if ( $block->getReason() ) {
+                               $reason = $block->getReason();
                        } else {
                                $msg = \Message::newFromKey( 'blockednoreason' );
                                if ( !\RequestContext::getMain()->getUser()->isSafeToLoad() ) {
index 02a8d00..0cf790b 100644 (file)
@@ -350,9 +350,11 @@ class SpecialBlock extends FormSpecialPage {
 
                $block = Block::newFromTarget( $this->target );
 
-               if ( $block instanceof Block && !$block->mAuto # The block exists and isn't an autoblock
-                       && ( $this->type != Block::TYPE_RANGE # The block isn't a rangeblock
-                               || $block->getTarget() == $this->target ) # or if it is, the range is what we're about to block
+               // Populate fields if there is a block that is not an autoblock; if it is a range
+               // block, only populate the fields if the range is the same as $this->target
+               if ( $block instanceof Block && $block->getType() !== Block::TYPE_AUTO
+                       && ( $this->type != Block::TYPE_RANGE
+                               || $block->getTarget() == $this->target )
                ) {
                        $fields['HardBlock']['default'] = $block->isHardblock();
                        $fields['CreateAccount']['default'] = $block->isCreateAccountBlocked();
@@ -363,7 +365,7 @@ class SpecialBlock extends FormSpecialPage {
                        }
 
                        if ( isset( $fields['HideUser'] ) ) {
-                               $fields['HideUser']['default'] = $block->mHideName;
+                               $fields['HideUser']['default'] = $block->getHideName();
                        }
 
                        if ( isset( $fields['DisableUTEdit'] ) ) {
@@ -372,8 +374,8 @@ class SpecialBlock extends FormSpecialPage {
 
                        // If the username was hidden (ipb_deleted == 1), don't show the reason
                        // unless this user also has rights to hideuser: T37839
-                       if ( !$block->mHideName || $this->getUser()->isAllowed( 'hideuser' ) ) {
-                               $fields['Reason']['default'] = $block->mReason;
+                       if ( !$block->getHideName() || $this->getUser()->isAllowed( 'hideuser' ) ) {
+                               $fields['Reason']['default'] = $block->getReason();
                        } else {
                                $fields['Reason']['default'] = '';
                        }
@@ -389,10 +391,10 @@ class SpecialBlock extends FormSpecialPage {
                                $fields['Confirm']['default'] = 1;
                        }
 
-                       if ( $block->mExpiry == 'infinity' ) {
+                       if ( $block->getExpiry() == 'infinity' ) {
                                $fields['Expiry']['default'] = 'infinite';
                        } else {
-                               $fields['Expiry']['default'] = wfTimestamp( TS_RFC2822, $block->mExpiry );
+                               $fields['Expiry']['default'] = wfTimestamp( TS_RFC2822, $block->getExpiry() );
                        }
 
                        $fields['BlockId']['default'] = $block->getId();
@@ -873,14 +875,14 @@ class SpecialBlock extends FormSpecialPage {
                $block = new Block();
                $block->setTarget( $target );
                $block->setBlocker( $performer );
-               $block->mReason = $data['Reason'][0];
-               $block->mExpiry = $expiryTime;
+               $block->setReason( $data['Reason'][0] );
+               $block->setExpiry( $expiryTime );
                $block->isCreateAccountBlocked( $data['CreateAccount'] );
                $block->isUsertalkEditAllowed( !$wgBlockAllowsUTEdit || !$data['DisableUTEdit'] );
                $block->isEmailBlocked( $data['DisableEmail'] );
                $block->isHardblock( $data['HardBlock'] );
                $block->isAutoblocking( $data['AutoBlock'] );
-               $block->mHideName = $data['HideUser'];
+               $block->setHideName( $data['HideUser'] );
 
                if ( $isPartialBlock ) {
                        $block->isSitewide( false );
@@ -939,19 +941,19 @@ class SpecialBlock extends FormSpecialPage {
                                }
                                # If the name was hidden and the blocking user cannot hide
                                # names, then don't allow any block changes...
-                               if ( $currentBlock->mHideName && !$performer->isAllowed( 'hideuser' ) ) {
+                               if ( $currentBlock->getHideName() && !$performer->isAllowed( 'hideuser' ) ) {
                                        return [ 'cant-see-hidden-user' ];
                                }
 
                                $priorBlock = clone $currentBlock;
                                $currentBlock->isHardblock( $block->isHardblock() );
                                $currentBlock->isCreateAccountBlocked( $block->isCreateAccountBlocked() );
-                               $currentBlock->mExpiry = $block->mExpiry;
+                               $currentBlock->setExpiry( $block->getExpiry() );
                                $currentBlock->isAutoblocking( $block->isAutoblocking() );
-                               $currentBlock->mHideName = $block->mHideName;
+                               $currentBlock->setHideName( $block->getHideName() );
                                $currentBlock->isEmailBlocked( $block->isEmailBlocked() );
                                $currentBlock->isUsertalkEditAllowed( $block->isUsertalkEditAllowed() );
-                               $currentBlock->mReason = $block->mReason;
+                               $currentBlock->setReason( $block->getReason() );
 
                                if ( $enablePartialBlocks ) {
                                        // Maintain the sitewide status. If partial blocks is not enabled,
@@ -970,12 +972,12 @@ class SpecialBlock extends FormSpecialPage {
                                $logaction = 'reblock';
 
                                # Unset _deleted fields if requested
-                               if ( $currentBlock->mHideName && !$data['HideUser'] ) {
+                               if ( $currentBlock->getHideName() && !$data['HideUser'] ) {
                                        RevisionDeleteUser::unsuppressUserName( $target, $userId );
                                }
 
                                # If hiding/unhiding a name, this should go in the private logs
-                               if ( (bool)$currentBlock->mHideName ) {
+                               if ( (bool)$currentBlock->getHideName() ) {
                                        $data['HideUser'] = true;
                                }
 
index 632415c..a04fe4e 100644 (file)
@@ -205,7 +205,7 @@ class SpecialUnblock extends SpecialPage {
 
                # If the name was hidden and the blocking user cannot hide
                # names, then don't allow any block removals...
-               if ( !$performer->isAllowed( 'hideuser' ) && $block->mHideName ) {
+               if ( !$performer->isAllowed( 'hideuser' ) && $block->getHideName() ) {
                        return [ 'unblock-hideuser' ];
                }
 
@@ -222,7 +222,7 @@ class SpecialUnblock extends SpecialPage {
                Hooks::run( 'UnblockUserComplete', [ $block, $performer ] );
 
                # Unset _deleted fields as needed
-               if ( $block->mHideName ) {
+               if ( $block->getHideName() ) {
                        # Something is deeply FUBAR if this is not a User object, but who knows?
                        $id = $block->getTarget() instanceof User
                                ? $block->getTarget()->getId()
index 1c5c9e8..44df557 100644 (file)
@@ -1896,7 +1896,7 @@ class User implements IDBAccessObject, UserIdentity {
                        if ( $block instanceof Block ) {
                                # Mangle the reason to alert the user that the block
                                # originated from matching the X-Forwarded-For header.
-                               $block->mReason = wfMessage( 'xffblockreason', $block->mReason )->plain();
+                               $block->setReason( wfMessage( 'xffblockreason', $block->getReason() )->plain() );
                        }
                }
 
@@ -1918,8 +1918,8 @@ class User implements IDBAccessObject, UserIdentity {
                        wfDebug( __METHOD__ . ": Found block.\n" );
                        $this->mBlock = $block;
                        $this->mBlockedby = $block->getByName();
-                       $this->mBlockreason = $block->mReason;
-                       $this->mHideName = $block->mHideName;
+                       $this->mBlockreason = $block->getReason();
+                       $this->mHideName = $block->getHideName();
                        $this->mAllowUsertalk = $block->isUsertalkEditAllowed();
                } else {
                        $this->mBlock = null;
index 50a4e2f..7874688 100644 (file)
@@ -94,7 +94,7 @@ class BlockTest extends MediaWikiLangTestCase {
                $madeAt = wfTimestamp( TS_MW );
 
                // delta to stop one-off errors when things happen to go over a second mark.
-               $delta = abs( $madeAt - $block->mTimestamp );
+               $delta = abs( $madeAt - $block->getTimestamp() );
                $this->assertLessThan(
                        2,
                        $delta,
@@ -302,8 +302,8 @@ class BlockTest extends MediaWikiLangTestCase {
                        $block = new Block();
                        $block->setTarget( $target );
                        $block->setBlocker( $blocker );
-                       $block->mReason = $insBlock['desc'];
-                       $block->mExpiry = 'infinity';
+                       $block->setReason( $insBlock['desc'] );
+                       $block->setExpiry( 'infinity' );
                        $block->isCreateAccountBlocked( $insBlock['ACDisable'] );
                        $block->isHardblock( $insBlock['isHardblock'] );
                        $block->isAutoblocking( $insBlock['isAutoBlocking'] );
@@ -369,7 +369,9 @@ class BlockTest extends MediaWikiLangTestCase {
                $xffblocks = Block::getBlocksForIPList( $list, true );
                $this->assertEquals( $exCount, count( $xffblocks ), 'Number of blocks for ' . $xff );
                $block = Block::chooseBlock( $xffblocks, $list );
-               $this->assertEquals( $exResult, $block->mReason, 'Correct block type for XFF header ' . $xff );
+               $this->assertEquals(
+                       $exResult, $block->getReason(), 'Correct block type for XFF header ' . $xff
+               );
        }
 
        /**
index 3d8c643..13def70 100644 (file)
@@ -923,7 +923,7 @@ class TitlePermissionTest extends MediaWikiLangTestCase {
                        'auto' => true,
                        'expiry' => 0
                ] );
-               $this->user->mBlock->mTimestamp = 0;
+               $this->user->mBlock->setTimestamp( 0 );
                $this->assertEquals( [ [ 'autoblockedtext',
                                '[[User:Useruser|Useruser]]', 'no reason given', '127.0.0.1',
                                'Useruser', null, 'infinite', '127.0.8.1',
index 01455ed..7274a54 100644 (file)
@@ -62,7 +62,7 @@ class ApiBlockTest extends ApiTestCase {
                $this->assertTrue( !is_null( $block ), 'Block is valid' );
 
                $this->assertSame( $this->mUser->getName(), (string)$block->getTarget() );
-               $this->assertSame( 'Some reason', $block->mReason );
+               $this->assertSame( 'Some reason', $block->getReason() );
 
                return $ret;
        }
index 91f12f4..182ca0d 100644 (file)
@@ -91,7 +91,7 @@ class SpecialBlockTest extends SpecialPageTestBase {
                $this->assertSame( $block->isCreateAccountBlocked(), $fields['CreateAccount']['default'] );
                $this->assertSame( $block->isAutoblocking(), $fields['AutoBlock']['default'] );
                $this->assertSame( !$block->isUsertalkEditAllowed(), $fields['DisableUTEdit']['default'] );
-               $this->assertSame( $block->mReason, $fields['Reason']['default'] );
+               $this->assertSame( $block->getReason(), $fields['Reason']['default'] );
                $this->assertSame( 'infinite', $fields['Expiry']['default'] );
        }
 
@@ -179,7 +179,7 @@ class SpecialBlockTest extends SpecialPageTestBase {
                $this->assertTrue( $result );
 
                $block = Block::newFromTarget( $badActor );
-               $this->assertSame( $reason, $block->mReason );
+               $this->assertSame( $reason, $block->getReason() );
                $this->assertSame( $expiry, $block->getExpiry() );
        }
 
@@ -228,7 +228,7 @@ class SpecialBlockTest extends SpecialPageTestBase {
                $this->assertTrue( $result );
 
                $block = Block::newFromTarget( $badActor );
-               $this->assertSame( $reason, $block->mReason );
+               $this->assertSame( $reason, $block->getReason() );
                $this->assertSame( $expiry, $block->getExpiry() );
                $this->assertSame( '1', $block->isAutoblocking() );
        }
@@ -277,7 +277,7 @@ class SpecialBlockTest extends SpecialPageTestBase {
                $this->assertTrue( $result );
 
                $block = Block::newFromTarget( $badActor );
-               $this->assertSame( $reason, $block->mReason );
+               $this->assertSame( $reason, $block->getReason() );
                $this->assertSame( $expiry, $block->getExpiry() );
                $this->assertCount( 2, $block->getRestrictions() );
                $this->assertTrue( BlockRestriction::equals( $block->getRestrictions(), [
@@ -331,7 +331,7 @@ class SpecialBlockTest extends SpecialPageTestBase {
                $this->assertTrue( $result );
 
                $block = Block::newFromTarget( $badActor );
-               $this->assertSame( $reason, $block->mReason );
+               $this->assertSame( $reason, $block->getReason() );
                $this->assertSame( $expiry, $block->getExpiry() );
                $this->assertFalse( $block->isSitewide() );
                $this->assertCount( 2, $block->getRestrictions() );
@@ -347,7 +347,7 @@ class SpecialBlockTest extends SpecialPageTestBase {
                $this->assertTrue( $result );
 
                $block = Block::newFromTarget( $badActor );
-               $this->assertSame( $reason, $block->mReason );
+               $this->assertSame( $reason, $block->getReason() );
                $this->assertSame( $expiry, $block->getExpiry() );
                $this->assertFalse( $block->isSitewide() );
                $this->assertCount( 1, $block->getRestrictions() );
@@ -362,7 +362,7 @@ class SpecialBlockTest extends SpecialPageTestBase {
                $this->assertTrue( $result );
 
                $block = Block::newFromTarget( $badActor );
-               $this->assertSame( $reason, $block->mReason );
+               $this->assertSame( $reason, $block->getReason() );
                $this->assertSame( $expiry, $block->getExpiry() );
                $this->assertFalse( $block->isSitewide() );
                $this->assertCount( 0, $block->getRestrictions() );
@@ -374,7 +374,7 @@ class SpecialBlockTest extends SpecialPageTestBase {
                $this->assertTrue( $result );
 
                $block = Block::newFromTarget( $badActor );
-               $this->assertSame( $reason, $block->mReason );
+               $this->assertSame( $reason, $block->getReason() );
                $this->assertSame( $expiry, $block->getExpiry() );
                $this->assertTrue( $block->isSitewide() );
                $this->assertCount( 0, $block->getRestrictions() );
index 642e8b4..f84be3f 100644 (file)
@@ -757,7 +757,7 @@ class UserTest extends MediaWikiTestCase {
 
                // 3. Change the block's expiry (to 2 hours), and the cookie's should be changed also.
                $newExpiry = wfTimestamp() + 2 * 60 * 60;
-               $block->mExpiry = wfTimestamp( TS_MW, $newExpiry );
+               $block->setExpiry( wfTimestamp( TS_MW, $newExpiry ) );
                $block->update();
                $user2tmp = $this->getTestUser()->getUser();
                $request2 = new FauxRequest();