Revert "Store block reasons as CommentStoreComments in block classes"

This reverts commit 9335363789.

Reason for revert: It's full of code accessing AbstractBlock::mReason
out there, see [1]. Also, it was never hard deprecated. While that may
be acceptable under some circumstances, it's definitely not OK to remove
code when there are consumers around. I'd have fixed it right now without
reverting if it were a single repo, but there's just too many.

[1] - https://codesearch.wmflabs.org/search/?q=-%3EmReason&i=nope&files=&repos=

Change-Id: I8669f502b50cff89e28dada0f65fe2b130ae9b37
This commit is contained in:
Daimona Eaytoy 2019-10-19 18:53:02 +00:00
parent 9335363789
commit 5f06efb318
16 changed files with 81 additions and 167 deletions

View file

@ -90,7 +90,6 @@ because of Phabricator reports.
Construct WANObjectCache directly instead, or use MediaWikiServices.
* ApiQueryUserInfo::getBlockInfo, deprecated in 1.34, was removed. Use
ApiBlockInfoTrait::getBlockDetails instead.
* AbstractBlock::mReason, deprecated in 1.34, is no longer public.
* …
=== Deprecations in 1.35 ===
@ -104,11 +103,6 @@ because of Phabricator reports.
methods on the LanguageFallback class: getFirst, getAll, and
getAllIncludingSiteLanguage.
* Title::countRevisionsBetween has been deprecated and moved into RevisionStore.
* AbstractBlock::getReason is deprecated, since reasons are actually stored as
CommentStoreComments, and getReason returns a string with no caller control
over language or formatting. Instead use AbstractBlock::getReasonComment,
which returns the CommentStoreComment.
* …
=== Other changes in 1.35 ===
* …

View file

@ -29,7 +29,6 @@ trait ApiBlockInfoTrait {
/**
* Get basic info about a given block
* @param AbstractBlock $block
* @param Language|null $language
* @return array Array containing several keys:
* - blockid - ID of the block
* - blockedby - username of the blocker
@ -40,20 +39,12 @@ trait ApiBlockInfoTrait {
* - blockpartial - block only applies to certain pages, namespaces and/or actions
* - systemblocktype - system block type, if any
*/
private function getBlockDetails(
AbstractBlock $block,
$language = null
) {
if ( $language === null ) {
$language = $this->getLanguage();
}
private function getBlockDetails( AbstractBlock $block ) {
$vals = [];
$vals['blockid'] = $block->getId();
$vals['blockedby'] = $block->getByName();
$vals['blockedbyid'] = $block->getBy();
$vals['blockreason'] = $block->getReasonComment()
->message->inLanguage( $language )->plain();
$vals['blockreason'] = $block->getReason();
$vals['blockedtimestamp'] = wfTimestamp( TS_ISO_8601, $block->getTimestamp() );
$vals['blockexpiry'] = ApiResult::formatExpiry( $block->getExpiry(), 'infinite' );
$vals['blockpartial'] = !$block->isSitewide();
@ -63,14 +54,4 @@ trait ApiBlockInfoTrait {
return $vals;
}
/**
* @name Methods required from ApiBase
* @{
*/
/** @see IContextSource::getLanguage */
abstract public function getLanguage();
/**@}*/
}

View file

@ -1008,12 +1008,10 @@ class AuthManager implements LoggerAwareInterface {
$block = $creator->isBlockedFromCreateAccount();
if ( $block ) {
$language = \RequestContext::getMain()->getLanguage();
$errorParams = [
$language->embedBidi( $block->getTarget() ),
$block->getReasonComment()->message->inLanguage( $language )->plain(),
$language->embedBidi( $block->getByName() ),
$block->getTarget(),
$block->getReason() ?: wfMessage( 'blockednoreason' )->text(),
$block->getByName()
];
if ( $block->getType() === DatabaseBlock::TYPE_RANGE ) {

View file

@ -23,7 +23,6 @@ namespace MediaWiki\Auth;
use Config;
use MediaWiki\Block\DatabaseBlock;
use MediaWiki\MediaWikiServices;
use StatusValue;
/**
@ -81,14 +80,20 @@ class CheckBlocksSecondaryAuthenticationProvider extends AbstractSecondaryAuthen
public function testUserForCreation( $user, $autocreate, array $options = [] ) {
$block = $user->isBlockedFromCreateAccount();
if ( $block ) {
$language = \RequestContext::getMain()->getUser()->isSafeToLoad() ?
\RequestContext::getMain()->getLanguage() :
MediaWikiServices::getInstance()->getContentLanguage();
if ( $block->getReason() ) {
$reason = $block->getReason();
} else {
$msg = \Message::newFromKey( 'blockednoreason' );
if ( !\RequestContext::getMain()->getUser()->isSafeToLoad() ) {
$msg->inContentLanguage();
}
$reason = $msg->text();
}
$errorParams = [
$language->embedBidi( $block->getTarget() ),
$block->getReasonComment()->message->inLanguage( $language )->plain(),
$language->embedBidi( $block->getByName() ),
$block->getTarget(),
$reason,
$block->getByName()
];
if ( $block->getType() === DatabaseBlock::TYPE_RANGE ) {

View file

@ -20,12 +20,10 @@
namespace MediaWiki\Block;
use CommentStoreComment;
use IContextSource;
use InvalidArgumentException;
use IP;
use MediaWiki\MediaWikiServices;
use Message;
use RequestContext;
use Title;
use User;
@ -35,13 +33,10 @@ use User;
*/
abstract class AbstractBlock {
/**
* @deprecated since 1.34. Use getReasonComment and setReason instead.
* Internally, use $reason.
* @deprecated since 1.34. Use getReason and setReason instead.
* @var string
*/
private $mReason;
/** @var CommentStoreComment */
protected $reason;
public $mReason;
/**
* @deprecated since 1.34. Use getTimestamp and setTimestamp instead.
@ -98,7 +93,7 @@ abstract class AbstractBlock {
* @param array $options Parameters of the block, with supported options:
* - address: (string|User) Target user name, User object, IP address or IP range
* - by: (int) User ID of the blocker
* - reason: (string|Message|CommentStoreComment) Reason for the block
* - reason: (string) Reason of the block
* - timestamp: (string) The time at which the block comes into effect
* - byText: (string) Username of the blocker (for foreign users)
* - hideName: (bool) Hide the target user name
@ -166,38 +161,23 @@ abstract class AbstractBlock {
abstract public function getIdentifier();
/**
* Get the reason given for creating the block, as a string.
* Get the reason given for creating the block
*
* Deprecated, since this gives the caller no control over the language
* or format, and no access to the comment's data.
*
* @deprecated since 1.35. Use getReasonComment instead.
* @since 1.33
* @return string
*/
public function getReason() {
$language = RequestContext::getMain()->getLanguage();
return $this->reason->message->inLanguage( $language )->plain();
return $this->mReason;
}
/**
* Get the reason for creating the block.
*
* @since 1.35
* @return CommentStoreComment
*/
public function getReasonComment() {
return $this->reason;
}
/**
* Set the reason for creating the block.
* Set the reason for creating the block
*
* @since 1.33
* @param string|Message|CommentStoreComment $reason
* @param string $reason
*/
public function setReason( $reason ) {
$this->reason = CommentStoreComment::newUnsavedComment( $reason );
$this->mReason = $reason;
}
/**

View file

@ -20,7 +20,6 @@
namespace MediaWiki\Block;
use CommentStoreComment;
use Language;
use Message;
use User;
@ -73,7 +72,7 @@ class BlockErrorFormatter {
'targetName' => (string)$block->getTarget(),
'blockerName' => $block->getByName(),
'blockerId' => $block->getBy(),
'reason' => $block->getReasonComment(),
'reason' => $block->getReason(),
'expiry' => $block->getExpiry(),
'timestamp' => $block->getTimestamp(),
];
@ -83,7 +82,6 @@ class BlockErrorFormatter {
* Get a standard set of block details for building a block error message,
* formatted for a specified user and language.
*
* @since 1.35
* @param AbstractBlock $block
* @param User $user
* @param Language $language
@ -107,18 +105,16 @@ class BlockErrorFormatter {
}
/**
* Format the block reason as plain wikitext in the specified language.
*
* @param CommentStoreComment $reason
* @param string $reason
* @param Language $language
* @return string
*/
private function formatBlockReason( CommentStoreComment $reason, Language $language ) {
if ( $reason->text === '' ) {
private function formatBlockReason( $reason, Language $language ) {
if ( $reason === '' ) {
$message = new Message( 'blockednoreason', [], $language );
return $message->text();
}
return $reason->message->inLanguage( $language )->plain();
return $reason;
}
/**

View file

@ -28,7 +28,6 @@ use LogicException;
use MediaWiki\Config\ServiceOptions;
use MediaWiki\Permissions\PermissionManager;
use MediaWiki\User\UserIdentity;
use Message;
use MWCryptHash;
use Psr\Log\LoggerInterface;
use User;
@ -159,7 +158,7 @@ class BlockManager {
$block = new CompositeBlock( [
'address' => $ip,
'byText' => 'MediaWiki default',
'reason' => new Message( 'blockedtext-composite-reason' ),
'reason' => wfMessage( 'blockedtext-composite-reason' )->plain(),
'originalBlocks' => $blocks,
] );
}
@ -203,14 +202,14 @@ class BlockManager {
if ( $this->isLocallyBlockedProxy( $ip ) ) {
$blocks[] = new SystemBlock( [
'byText' => wfMessage( 'proxyblocker' )->text(),
'reason' => new Message( 'proxyblockreason' ),
'reason' => wfMessage( 'proxyblockreason' )->plain(),
'address' => $ip,
'systemBlock' => 'proxy',
] );
} elseif ( $isAnon && $this->isDnsBlacklisted( $ip ) ) {
$blocks[] = new SystemBlock( [
'byText' => wfMessage( 'sorbs' )->text(),
'reason' => new Message( 'sorbsreason' ),
'reason' => wfMessage( 'sorbsreason' )->plain(),
'address' => $ip,
'systemBlock' => 'dnsbl',
] );
@ -222,7 +221,7 @@ class BlockManager {
$blocks[] = new SystemBlock( [
'address' => $ip,
'byText' => 'MediaWiki default',
'reason' => new Message( 'softblockrangesreason', [ $ip ] ),
'reason' => wfMessage( 'softblockrangesreason', $ip )->plain(),
'anonOnly' => true,
'systemBlock' => 'wgSoftBlockRanges',
] );

View file

@ -211,7 +211,7 @@ class DatabaseBlock extends AbstractBlock {
&& $this->getHideName() == $block->getHideName()
&& $this->isEmailBlocked() == $block->isEmailBlocked()
&& $this->isUsertalkEditAllowed() == $block->isUsertalkEditAllowed()
&& $this->getReasonComment()->text == $block->getReasonComment()->text
&& $this->getReason() == $block->getReason()
&& $this->isSitewide() == $block->isSitewide()
// DatabaseBlock::getRestrictions() may perform a database query, so
// keep it at the end.
@ -436,7 +436,7 @@ class DatabaseBlock extends AbstractBlock {
$this->setReason(
CommentStore::getStore()
// Legacy because $row may have come from self::selectFields()
->getCommentLegacy( $db, 'ipb_reason', $row )
->getCommentLegacy( $db, 'ipb_reason', $row )->text
);
$this->isHardblock( !$row->ipb_anon_only );
@ -657,7 +657,7 @@ class DatabaseBlock extends AbstractBlock {
'ipb_allow_usertalk' => $this->isUsertalkEditAllowed(),
'ipb_parent_block_id' => $this->mParentBlockId,
'ipb_sitewide' => $this->isSitewide(),
] + CommentStore::getStore()->insert( $dbw, 'ipb_reason', $this->getReasonComment() )
] + CommentStore::getStore()->insert( $dbw, 'ipb_reason', $this->getReason() )
+ ActorMigration::newMigration()->getInsertValues( $dbw, 'ipb_by', $this->getBlocker() );
return $a;
@ -673,7 +673,7 @@ class DatabaseBlock extends AbstractBlock {
'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->getReasonComment() )
] + CommentStore::getStore()->insert( $dbw, 'ipb_reason', $this->getReason() )
+ ActorMigration::newMigration()->getInsertValues( $dbw, 'ipb_by', $this->getBlocker() );
}
@ -847,7 +847,8 @@ class DatabaseBlock extends AbstractBlock {
$autoblock->setTarget( $autoblockIP );
$autoblock->setBlocker( $this->getBlocker() );
$autoblock->setReason(
wfMessage( 'autoblocker', $this->getTarget(), $this->getReasonComment()->text )
wfMessage( 'autoblocker', $this->getTarget(), $this->getReason() )
->inContentLanguage()->plain()
);
$timestamp = wfTimestampNow();
$autoblock->setTimestamp( $timestamp );
@ -979,17 +980,6 @@ class DatabaseBlock extends AbstractBlock {
}
}
/**
* @inheritDoc
* @deprecated since 1.35. Use getReasonComment instead.
*/
public function getReason() {
if ( $this->getType() === self::TYPE_AUTO ) {
return $this->reason->message->inContentLanguage()->plain();
}
return $this->reason->text;
}
/**
* @inheritDoc
*/

View file

@ -371,7 +371,7 @@ class SpecialBlock extends FormSpecialPage {
->getPermissionManager()
->userHasRight( $this->getUser(), 'hideuser' )
) {
$fields['Reason']['default'] = $block->getReasonComment()->text;
$fields['Reason']['default'] = $block->getReason();
} else {
$fields['Reason']['default'] = '';
}
@ -964,7 +964,7 @@ class SpecialBlock extends FormSpecialPage {
$currentBlock->setHideName( $block->getHideName() );
$currentBlock->isEmailBlocked( $block->isEmailBlocked() );
$currentBlock->isUsertalkEditAllowed( $block->isUsertalkEditAllowed() );
$currentBlock->setReason( $block->getReasonComment() );
$currentBlock->setReason( $block->getReason() );
if ( $enablePartialBlocks ) {
// Maintain the sitewide status. If partial blocks is not enabled,

View file

@ -180,11 +180,7 @@ class User implements IDBAccessObject, UserIdentity {
public $mBlockedby;
/** @var string */
protected $mHash;
/**
* TODO: This should be removed when User::BlockedFor
* and AbstractBlock::getReason are hard deprecated.
* @var string
*/
/** @var string */
protected $mBlockreason;
/** @var array */
protected $mEffectiveGroups;
@ -2097,9 +2093,7 @@ class User implements IDBAccessObject, UserIdentity {
}
/**
* If user is blocked, return the specified reason for the block.
*
* @deprecated since 1.35 Use AbstractBlock::getReasonComment instead
* If user is blocked, return the specified reason for the block
* @return string Blocking reason
*/
public function blockedFor() {

View file

@ -1342,10 +1342,9 @@ class ApiBaseTest extends ApiTestCase {
'expiry' => time() + 100500,
] );
$block->insert();
$mockTrait = $this->getMockForTrait( ApiBlockInfoTrait::class );
$mockTrait->method( 'getLanguage' )->willReturn( 'en' );
$userInfoTrait = TestingAccessWrapper::newFromObject( $mockTrait );
$userInfoTrait = TestingAccessWrapper::newFromObject(
$this->getMockForTrait( ApiBlockInfoTrait::class )
);
$blockinfo = [ 'blockinfo' => $userInfoTrait->getBlockDetails( $block ) ];
$expect = Status::newGood();
@ -1401,10 +1400,9 @@ class ApiBaseTest extends ApiTestCase {
'expiry' => time() + 100500,
] );
$block->insert();
$mockTrait = $this->getMockForTrait( ApiBlockInfoTrait::class );
$mockTrait->method( 'getLanguage' )->willReturn( 'en' );
$userInfoTrait = TestingAccessWrapper::newFromObject( $mockTrait );
$userInfoTrait = TestingAccessWrapper::newFromObject(
$this->getObjectForTrait( ApiBlockInfoTrait::class )
);
$blockinfo = [ 'blockinfo' => $userInfoTrait->getBlockDetails( $block ) ];
$expect = Status::newGood();

View file

@ -13,7 +13,6 @@ class ApiBlockInfoTraitTest extends MediaWikiTestCase {
*/
public function testGetBlockDetails( $block, $expectedInfo ) {
$mock = $this->getMockForTrait( ApiBlockInfoTrait::class );
$mock->method( 'getLanguage' )->willReturn( 'en' );
$info = TestingAccessWrapper::newFromObject( $mock )->getBlockDetails( $block );
$subset = array_merge( [
'blockid' => null,

View file

@ -66,7 +66,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->getReasonComment()->text );
$this->assertSame( 'Some reason', $block->getReason() );
return $ret;
}

View file

@ -9,7 +9,7 @@ use MediaWiki\MediaWikiServices;
* @group Blocking
* @coversDefaultClass \MediaWiki\Block\BlockErrorFormatter
*/
class BlockErrorFormatterTest extends MediaWikiTestCase {
class BlockErrorFormatterTest extends MediaWikiLangTestCase {
/**
* @dataProvider provideTestGetMessage
* @covers ::getMessage
@ -31,7 +31,7 @@ class BlockErrorFormatterTest extends MediaWikiTestCase {
$message = $formatter->getMessage(
$block,
$context->getUser(),
Language::factory( 'qqx' ),
$context->getLanguage(),
$context->getRequest()->getIP()
);
@ -46,13 +46,11 @@ class BlockErrorFormatterTest extends MediaWikiTestCase {
$databaseBlock = new DatabaseBlock( [
'timestamp' => $timestamp,
'expiry' => $expiry,
'reason' => 'Test reason.',
] );
$systemBlock = new SystemBlock( [
'timestamp' => $timestamp,
'systemBlock' => 'test',
'reason' => new Message( 'proxyblockreason' ),
] );
$compositeBlock = new CompositeBlock( [
@ -69,13 +67,13 @@ class BlockErrorFormatterTest extends MediaWikiTestCase {
'blockedtext',
[
'',
'Test reason.',
'no reason given',
'1.2.3.4',
'',
null, // Block not inserted
'00:00, 1 (january) 2001',
'00:00, 1 January 2001',
'',
'00:00, 1 (january) 2000',
'00:00, 1 January 2000',
],
],
'Database block (autoblock)' => [
@ -87,13 +85,13 @@ class BlockErrorFormatterTest extends MediaWikiTestCase {
'autoblockedtext',
[
'',
'(blockednoreason)',
'no reason given',
'1.2.3.4',
'',
null, // Block not inserted
'00:00, 1 (january) 2001',
null,
'00:00, 1 January 2001',
'',
'00:00, 1 (january) 2000',
'00:00, 1 January 2000',
],
],
'Database block (partial block)' => [
@ -105,13 +103,13 @@ class BlockErrorFormatterTest extends MediaWikiTestCase {
'blockedtext-partial',
[
'',
'(blockednoreason)',
'no reason given',
'1.2.3.4',
'',
null, // Block not inserted
'00:00, 1 (january) 2001',
null,
'00:00, 1 January 2001',
'',
'00:00, 1 (january) 2000',
'00:00, 1 January 2000',
],
],
'System block (type \'test\')' => [
@ -119,31 +117,13 @@ class BlockErrorFormatterTest extends MediaWikiTestCase {
'systemblockedtext',
[
'',
'(proxyblockreason)',
'no reason given',
'1.2.3.4',
'',
'test',
'(infiniteblock)',
'infinite',
'',
'00:00, 1 (january) 2000',
],
],
'System block (type \'test\') with reason parameters' => [
new SystemBlock( [
'timestamp' => $timestamp,
'systemBlock' => 'test',
'reason' => new Message( 'softblockrangesreason', [ '1.2.3.4' ] ),
] ),
'systemblockedtext',
[
'',
'(softblockrangesreason: 1.2.3.4)',
'1.2.3.4',
'',
'test',
'(infiniteblock)',
'',
'00:00, 1 (january) 2000',
'00:00, 1 January 2000',
],
],
'Composite block (original blocks not inserted)' => [
@ -151,13 +131,13 @@ class BlockErrorFormatterTest extends MediaWikiTestCase {
'blockedtext-composite',
[
'',
'(blockednoreason)',
'no reason given',
'1.2.3.4',
'',
'(blockedtext-composite-no-ids)',
'(infiniteblock)',
'Your IP address appears in multiple blacklists',
'infinite',
'',
'00:00, 1 (january) 2000',
'00:00, 1 January 2000',
],
],
];

View file

@ -445,7 +445,7 @@ class DatabaseBlockTest extends MediaWikiLangTestCase {
$this->assertEquals( $exCount, count( $xffblocks ), 'Number of blocks for ' . $xff );
$block = DatabaseBlock::chooseBlock( $xffblocks, $list );
$this->assertEquals(
$exResult, $block->getReasonComment()->text, 'Correct block type for XFF header ' . $xff
$exResult, $block->getReason(), 'Correct block type for XFF header ' . $xff
);
}

View file

@ -93,7 +93,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->getReasonComment()->text, $fields['Reason']['default'] );
$this->assertSame( $block->getReason(), $fields['Reason']['default'] );
$this->assertSame( 'infinite', $fields['Expiry']['default'] );
}
@ -181,7 +181,7 @@ class SpecialBlockTest extends SpecialPageTestBase {
$this->assertTrue( $result );
$block = DatabaseBlock::newFromTarget( $badActor );
$this->assertSame( $reason, $block->getReasonComment()->text );
$this->assertSame( $reason, $block->getReason() );
$this->assertSame( $expiry, $block->getExpiry() );
}
@ -230,7 +230,7 @@ class SpecialBlockTest extends SpecialPageTestBase {
$this->assertTrue( $result );
$block = DatabaseBlock::newFromTarget( $badActor );
$this->assertSame( $reason, $block->getReasonComment()->text );
$this->assertSame( $reason, $block->getReason() );
$this->assertSame( $expiry, $block->getExpiry() );
$this->assertSame( '1', $block->isAutoblocking() );
}
@ -279,7 +279,7 @@ class SpecialBlockTest extends SpecialPageTestBase {
$this->assertTrue( $result );
$block = DatabaseBlock::newFromTarget( $badActor );
$this->assertSame( $reason, $block->getReasonComment()->text );
$this->assertSame( $reason, $block->getReason() );
$this->assertSame( $expiry, $block->getExpiry() );
$this->assertCount( 2, $block->getRestrictions() );
$this->assertTrue( $this->getBlockRestrictionStore()->equals( $block->getRestrictions(), [
@ -333,7 +333,7 @@ class SpecialBlockTest extends SpecialPageTestBase {
$this->assertTrue( $result );
$block = DatabaseBlock::newFromTarget( $badActor );
$this->assertSame( $reason, $block->getReasonComment()->text );
$this->assertSame( $reason, $block->getReason() );
$this->assertSame( $expiry, $block->getExpiry() );
$this->assertFalse( $block->isSitewide() );
$this->assertCount( 2, $block->getRestrictions() );
@ -349,7 +349,7 @@ class SpecialBlockTest extends SpecialPageTestBase {
$this->assertTrue( $result );
$block = DatabaseBlock::newFromTarget( $badActor );
$this->assertSame( $reason, $block->getReasonComment()->text );
$this->assertSame( $reason, $block->getReason() );
$this->assertSame( $expiry, $block->getExpiry() );
$this->assertFalse( $block->isSitewide() );
$this->assertCount( 1, $block->getRestrictions() );
@ -364,7 +364,7 @@ class SpecialBlockTest extends SpecialPageTestBase {
$this->assertTrue( $result );
$block = DatabaseBlock::newFromTarget( $badActor );
$this->assertSame( $reason, $block->getReasonComment()->text );
$this->assertSame( $reason, $block->getReason() );
$this->assertSame( $expiry, $block->getExpiry() );
$this->assertFalse( $block->isSitewide() );
$this->assertCount( 0, $block->getRestrictions() );
@ -376,7 +376,7 @@ class SpecialBlockTest extends SpecialPageTestBase {
$this->assertTrue( $result );
$block = DatabaseBlock::newFromTarget( $badActor );
$this->assertSame( $reason, $block->getReasonComment()->text );
$this->assertSame( $reason, $block->getReason() );
$this->assertSame( $expiry, $block->getExpiry() );
$this->assertTrue( $block->isSitewide() );
$this->assertCount( 0, $block->getRestrictions() );