Revert "Revert "Store block reasons as CommentStoreComments in block classes""
This reverts commit5f06efb318, which reverted9335363789, which makes the deprecated property AbstractBlock::mReason private. After9335363789, AbstractBlock::mReason is obsolete, since the block reason is now stored as a CommentStoreComment, AbstractBlock::reason. Change-Id: Ica0a74be90383689ca8e4cfe6d0fb25c9a5942c5
This commit is contained in:
parent
84eac8a7fe
commit
a6533885b8
16 changed files with 167 additions and 81 deletions
|
|
@ -96,6 +96,7 @@ because of Phabricator reports.
|
|||
* ApiQueryUserInfo::getBlockInfo, deprecated in 1.34, was removed. Use
|
||||
ApiBlockInfoTrait::getBlockDetails instead.
|
||||
* The mediawiki.ui.text module, deprecated in 1.28 and unused, was removed.
|
||||
* AbstractBlock::mReason, deprecated in 1.34, is no longer public.
|
||||
* …
|
||||
|
||||
=== Deprecations in 1.35 ===
|
||||
|
|
@ -109,6 +110,11 @@ 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 ===
|
||||
* …
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ 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
|
||||
|
|
@ -39,12 +40,20 @@ trait ApiBlockInfoTrait {
|
|||
* - blockpartial - block only applies to certain pages, namespaces and/or actions
|
||||
* - systemblocktype - system block type, if any
|
||||
*/
|
||||
private function getBlockDetails( AbstractBlock $block ) {
|
||||
private function getBlockDetails(
|
||||
AbstractBlock $block,
|
||||
$language = null
|
||||
) {
|
||||
if ( $language === null ) {
|
||||
$language = $this->getLanguage();
|
||||
}
|
||||
|
||||
$vals = [];
|
||||
$vals['blockid'] = $block->getId();
|
||||
$vals['blockedby'] = $block->getByName();
|
||||
$vals['blockedbyid'] = $block->getBy();
|
||||
$vals['blockreason'] = $block->getReason();
|
||||
$vals['blockreason'] = $block->getReasonComment()
|
||||
->message->inLanguage( $language )->plain();
|
||||
$vals['blockedtimestamp'] = wfTimestamp( TS_ISO_8601, $block->getTimestamp() );
|
||||
$vals['blockexpiry'] = ApiResult::formatExpiry( $block->getExpiry(), 'infinite' );
|
||||
$vals['blockpartial'] = !$block->isSitewide();
|
||||
|
|
@ -54,4 +63,14 @@ trait ApiBlockInfoTrait {
|
|||
return $vals;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Methods required from ApiBase
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @see IContextSource::getLanguage */
|
||||
abstract public function getLanguage();
|
||||
|
||||
/**@}*/
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1008,10 +1008,12 @@ class AuthManager implements LoggerAwareInterface {
|
|||
|
||||
$block = $creator->isBlockedFromCreateAccount();
|
||||
if ( $block ) {
|
||||
$language = \RequestContext::getMain()->getLanguage();
|
||||
|
||||
$errorParams = [
|
||||
$block->getTarget(),
|
||||
$block->getReason() ?: wfMessage( 'blockednoreason' )->text(),
|
||||
$block->getByName()
|
||||
$language->embedBidi( $block->getTarget() ),
|
||||
$block->getReasonComment()->message->inLanguage( $language )->plain(),
|
||||
$language->embedBidi( $block->getByName() ),
|
||||
];
|
||||
|
||||
if ( $block->getType() === DatabaseBlock::TYPE_RANGE ) {
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ namespace MediaWiki\Auth;
|
|||
|
||||
use Config;
|
||||
use MediaWiki\Block\DatabaseBlock;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use StatusValue;
|
||||
|
||||
/**
|
||||
|
|
@ -80,20 +81,14 @@ class CheckBlocksSecondaryAuthenticationProvider extends AbstractSecondaryAuthen
|
|||
public function testUserForCreation( $user, $autocreate, array $options = [] ) {
|
||||
$block = $user->isBlockedFromCreateAccount();
|
||||
if ( $block ) {
|
||||
if ( $block->getReason() ) {
|
||||
$reason = $block->getReason();
|
||||
} else {
|
||||
$msg = \Message::newFromKey( 'blockednoreason' );
|
||||
if ( !\RequestContext::getMain()->getUser()->isSafeToLoad() ) {
|
||||
$msg->inContentLanguage();
|
||||
}
|
||||
$reason = $msg->text();
|
||||
}
|
||||
$language = \RequestContext::getMain()->getUser()->isSafeToLoad() ?
|
||||
\RequestContext::getMain()->getLanguage() :
|
||||
MediaWikiServices::getInstance()->getContentLanguage();
|
||||
|
||||
$errorParams = [
|
||||
$block->getTarget(),
|
||||
$reason,
|
||||
$block->getByName()
|
||||
$language->embedBidi( $block->getTarget() ),
|
||||
$block->getReasonComment()->message->inLanguage( $language )->plain(),
|
||||
$language->embedBidi( $block->getByName() ),
|
||||
];
|
||||
|
||||
if ( $block->getType() === DatabaseBlock::TYPE_RANGE ) {
|
||||
|
|
|
|||
|
|
@ -20,10 +20,12 @@
|
|||
|
||||
namespace MediaWiki\Block;
|
||||
|
||||
use CommentStoreComment;
|
||||
use IContextSource;
|
||||
use InvalidArgumentException;
|
||||
use IP;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use Message;
|
||||
use RequestContext;
|
||||
use Title;
|
||||
use User;
|
||||
|
|
@ -33,10 +35,13 @@ use User;
|
|||
*/
|
||||
abstract class AbstractBlock {
|
||||
/**
|
||||
* @deprecated since 1.34. Use getReason and setReason instead.
|
||||
* @var string
|
||||
* @deprecated since 1.34. Use getReasonComment and setReason instead.
|
||||
* Internally, use $reason.
|
||||
*/
|
||||
public $mReason;
|
||||
protected $mReason;
|
||||
|
||||
/** @var CommentStoreComment */
|
||||
protected $reason;
|
||||
|
||||
/**
|
||||
* @deprecated since 1.34. Use getTimestamp and setTimestamp instead.
|
||||
|
|
@ -93,7 +98,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) Reason of the block
|
||||
* - reason: (string|Message|CommentStoreComment) Reason for 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
|
||||
|
|
@ -161,23 +166,38 @@ abstract class AbstractBlock {
|
|||
abstract public function getIdentifier();
|
||||
|
||||
/**
|
||||
* Get the reason given for creating the block
|
||||
* Get the reason given for creating the block, as a string.
|
||||
*
|
||||
* 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() {
|
||||
return $this->mReason;
|
||||
$language = RequestContext::getMain()->getLanguage();
|
||||
return $this->reason->message->inLanguage( $language )->plain();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the reason for creating the block
|
||||
* 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.
|
||||
*
|
||||
* @since 1.33
|
||||
* @param string $reason
|
||||
* @param string|Message|CommentStoreComment $reason
|
||||
*/
|
||||
public function setReason( $reason ) {
|
||||
$this->mReason = $reason;
|
||||
$this->reason = CommentStoreComment::newUnsavedComment( $reason );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
namespace MediaWiki\Block;
|
||||
|
||||
use CommentStoreComment;
|
||||
use Language;
|
||||
use Message;
|
||||
use User;
|
||||
|
|
@ -72,7 +73,7 @@ class BlockErrorFormatter {
|
|||
'targetName' => (string)$block->getTarget(),
|
||||
'blockerName' => $block->getByName(),
|
||||
'blockerId' => $block->getBy(),
|
||||
'reason' => $block->getReason(),
|
||||
'reason' => $block->getReasonComment(),
|
||||
'expiry' => $block->getExpiry(),
|
||||
'timestamp' => $block->getTimestamp(),
|
||||
];
|
||||
|
|
@ -82,6 +83,7 @@ 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
|
||||
|
|
@ -105,16 +107,18 @@ class BlockErrorFormatter {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $reason
|
||||
* Format the block reason as plain wikitext in the specified language.
|
||||
*
|
||||
* @param CommentStoreComment $reason
|
||||
* @param Language $language
|
||||
* @return string
|
||||
*/
|
||||
private function formatBlockReason( $reason, Language $language ) {
|
||||
if ( $reason === '' ) {
|
||||
private function formatBlockReason( CommentStoreComment $reason, Language $language ) {
|
||||
if ( $reason->text === '' ) {
|
||||
$message = new Message( 'blockednoreason', [], $language );
|
||||
return $message->text();
|
||||
}
|
||||
return $reason;
|
||||
return $reason->message->inLanguage( $language )->plain();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ use LogicException;
|
|||
use MediaWiki\Config\ServiceOptions;
|
||||
use MediaWiki\Permissions\PermissionManager;
|
||||
use MediaWiki\User\UserIdentity;
|
||||
use Message;
|
||||
use MWCryptHash;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use User;
|
||||
|
|
@ -158,7 +159,7 @@ class BlockManager {
|
|||
$block = new CompositeBlock( [
|
||||
'address' => $ip,
|
||||
'byText' => 'MediaWiki default',
|
||||
'reason' => wfMessage( 'blockedtext-composite-reason' )->plain(),
|
||||
'reason' => new Message( 'blockedtext-composite-reason' ),
|
||||
'originalBlocks' => $blocks,
|
||||
] );
|
||||
}
|
||||
|
|
@ -202,14 +203,14 @@ class BlockManager {
|
|||
if ( $this->isLocallyBlockedProxy( $ip ) ) {
|
||||
$blocks[] = new SystemBlock( [
|
||||
'byText' => wfMessage( 'proxyblocker' )->text(),
|
||||
'reason' => wfMessage( 'proxyblockreason' )->plain(),
|
||||
'reason' => new Message( 'proxyblockreason' ),
|
||||
'address' => $ip,
|
||||
'systemBlock' => 'proxy',
|
||||
] );
|
||||
} elseif ( $isAnon && $this->isDnsBlacklisted( $ip ) ) {
|
||||
$blocks[] = new SystemBlock( [
|
||||
'byText' => wfMessage( 'sorbs' )->text(),
|
||||
'reason' => wfMessage( 'sorbsreason' )->plain(),
|
||||
'reason' => new Message( 'sorbsreason' ),
|
||||
'address' => $ip,
|
||||
'systemBlock' => 'dnsbl',
|
||||
] );
|
||||
|
|
@ -221,7 +222,7 @@ class BlockManager {
|
|||
$blocks[] = new SystemBlock( [
|
||||
'address' => $ip,
|
||||
'byText' => 'MediaWiki default',
|
||||
'reason' => wfMessage( 'softblockrangesreason', $ip )->plain(),
|
||||
'reason' => new Message( 'softblockrangesreason', [ $ip ] ),
|
||||
'anonOnly' => true,
|
||||
'systemBlock' => 'wgSoftBlockRanges',
|
||||
] );
|
||||
|
|
|
|||
|
|
@ -211,7 +211,7 @@ class DatabaseBlock extends AbstractBlock {
|
|||
&& $this->getHideName() == $block->getHideName()
|
||||
&& $this->isEmailBlocked() == $block->isEmailBlocked()
|
||||
&& $this->isUsertalkEditAllowed() == $block->isUsertalkEditAllowed()
|
||||
&& $this->getReason() == $block->getReason()
|
||||
&& $this->getReasonComment()->text == $block->getReasonComment()->text
|
||||
&& $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 )->text
|
||||
->getCommentLegacy( $db, 'ipb_reason', $row )
|
||||
);
|
||||
|
||||
$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->getReason() )
|
||||
] + CommentStore::getStore()->insert( $dbw, 'ipb_reason', $this->getReasonComment() )
|
||||
+ 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->getReason() )
|
||||
] + CommentStore::getStore()->insert( $dbw, 'ipb_reason', $this->getReasonComment() )
|
||||
+ ActorMigration::newMigration()->getInsertValues( $dbw, 'ipb_by', $this->getBlocker() );
|
||||
}
|
||||
|
||||
|
|
@ -847,8 +847,7 @@ class DatabaseBlock extends AbstractBlock {
|
|||
$autoblock->setTarget( $autoblockIP );
|
||||
$autoblock->setBlocker( $this->getBlocker() );
|
||||
$autoblock->setReason(
|
||||
wfMessage( 'autoblocker', $this->getTarget(), $this->getReason() )
|
||||
->inContentLanguage()->plain()
|
||||
wfMessage( 'autoblocker', $this->getTarget(), $this->getReasonComment()->text )
|
||||
);
|
||||
$timestamp = wfTimestampNow();
|
||||
$autoblock->setTimestamp( $timestamp );
|
||||
|
|
@ -980,6 +979,17 @@ 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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -371,7 +371,7 @@ class SpecialBlock extends FormSpecialPage {
|
|||
->getPermissionManager()
|
||||
->userHasRight( $this->getUser(), 'hideuser' )
|
||||
) {
|
||||
$fields['Reason']['default'] = $block->getReason();
|
||||
$fields['Reason']['default'] = $block->getReasonComment()->text;
|
||||
} 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->getReason() );
|
||||
$currentBlock->setReason( $block->getReasonComment() );
|
||||
|
||||
if ( $enablePartialBlocks ) {
|
||||
// Maintain the sitewide status. If partial blocks is not enabled,
|
||||
|
|
|
|||
|
|
@ -180,7 +180,11 @@ class User implements IDBAccessObject, UserIdentity {
|
|||
public $mBlockedby;
|
||||
/** @var string */
|
||||
protected $mHash;
|
||||
/** @var string */
|
||||
/**
|
||||
* TODO: This should be removed when User::BlockedFor
|
||||
* and AbstractBlock::getReason are hard deprecated.
|
||||
* @var string
|
||||
*/
|
||||
protected $mBlockreason;
|
||||
/** @var array */
|
||||
protected $mEffectiveGroups;
|
||||
|
|
@ -2093,7 +2097,9 @@ class User implements IDBAccessObject, UserIdentity {
|
|||
}
|
||||
|
||||
/**
|
||||
* If user is blocked, return the specified reason for the block
|
||||
* If user is blocked, return the specified reason for the block.
|
||||
*
|
||||
* @deprecated since 1.35 Use AbstractBlock::getReasonComment instead
|
||||
* @return string Blocking reason
|
||||
*/
|
||||
public function blockedFor() {
|
||||
|
|
|
|||
|
|
@ -1342,9 +1342,10 @@ class ApiBaseTest extends ApiTestCase {
|
|||
'expiry' => time() + 100500,
|
||||
] );
|
||||
$block->insert();
|
||||
$userInfoTrait = TestingAccessWrapper::newFromObject(
|
||||
$this->getMockForTrait( ApiBlockInfoTrait::class )
|
||||
);
|
||||
|
||||
$mockTrait = $this->getMockForTrait( ApiBlockInfoTrait::class );
|
||||
$mockTrait->method( 'getLanguage' )->willReturn( 'en' );
|
||||
$userInfoTrait = TestingAccessWrapper::newFromObject( $mockTrait );
|
||||
$blockinfo = [ 'blockinfo' => $userInfoTrait->getBlockDetails( $block ) ];
|
||||
|
||||
$expect = Status::newGood();
|
||||
|
|
@ -1400,9 +1401,10 @@ class ApiBaseTest extends ApiTestCase {
|
|||
'expiry' => time() + 100500,
|
||||
] );
|
||||
$block->insert();
|
||||
$userInfoTrait = TestingAccessWrapper::newFromObject(
|
||||
$this->getObjectForTrait( ApiBlockInfoTrait::class )
|
||||
);
|
||||
|
||||
$mockTrait = $this->getMockForTrait( ApiBlockInfoTrait::class );
|
||||
$mockTrait->method( 'getLanguage' )->willReturn( 'en' );
|
||||
$userInfoTrait = TestingAccessWrapper::newFromObject( $mockTrait );
|
||||
$blockinfo = [ 'blockinfo' => $userInfoTrait->getBlockDetails( $block ) ];
|
||||
|
||||
$expect = Status::newGood();
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ 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,
|
||||
|
|
|
|||
|
|
@ -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->getReason() );
|
||||
$this->assertSame( 'Some reason', $block->getReasonComment()->text );
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use MediaWiki\MediaWikiServices;
|
|||
* @group Blocking
|
||||
* @coversDefaultClass \MediaWiki\Block\BlockErrorFormatter
|
||||
*/
|
||||
class BlockErrorFormatterTest extends MediaWikiLangTestCase {
|
||||
class BlockErrorFormatterTest extends MediaWikiTestCase {
|
||||
/**
|
||||
* @dataProvider provideTestGetMessage
|
||||
* @covers ::getMessage
|
||||
|
|
@ -31,7 +31,7 @@ class BlockErrorFormatterTest extends MediaWikiLangTestCase {
|
|||
$message = $formatter->getMessage(
|
||||
$block,
|
||||
$context->getUser(),
|
||||
$context->getLanguage(),
|
||||
Language::factory( 'qqx' ),
|
||||
$context->getRequest()->getIP()
|
||||
);
|
||||
|
||||
|
|
@ -46,11 +46,13 @@ class BlockErrorFormatterTest extends MediaWikiLangTestCase {
|
|||
$databaseBlock = new DatabaseBlock( [
|
||||
'timestamp' => $timestamp,
|
||||
'expiry' => $expiry,
|
||||
'reason' => 'Test reason.',
|
||||
] );
|
||||
|
||||
$systemBlock = new SystemBlock( [
|
||||
'timestamp' => $timestamp,
|
||||
'systemBlock' => 'test',
|
||||
'reason' => new Message( 'proxyblockreason' ),
|
||||
] );
|
||||
|
||||
$compositeBlock = new CompositeBlock( [
|
||||
|
|
@ -67,13 +69,13 @@ class BlockErrorFormatterTest extends MediaWikiLangTestCase {
|
|||
'blockedtext',
|
||||
[
|
||||
'',
|
||||
'no reason given',
|
||||
'Test reason.',
|
||||
'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)' => [
|
||||
|
|
@ -85,13 +87,13 @@ class BlockErrorFormatterTest extends MediaWikiLangTestCase {
|
|||
'autoblockedtext',
|
||||
[
|
||||
'',
|
||||
'no reason given',
|
||||
'(blockednoreason)',
|
||||
'1.2.3.4',
|
||||
'',
|
||||
null,
|
||||
'00:00, 1 January 2001',
|
||||
null, // Block not inserted
|
||||
'00:00, 1 (january) 2001',
|
||||
'',
|
||||
'00:00, 1 January 2000',
|
||||
'00:00, 1 (january) 2000',
|
||||
],
|
||||
],
|
||||
'Database block (partial block)' => [
|
||||
|
|
@ -103,13 +105,13 @@ class BlockErrorFormatterTest extends MediaWikiLangTestCase {
|
|||
'blockedtext-partial',
|
||||
[
|
||||
'',
|
||||
'no reason given',
|
||||
'(blockednoreason)',
|
||||
'1.2.3.4',
|
||||
'',
|
||||
null,
|
||||
'00:00, 1 January 2001',
|
||||
null, // Block not inserted
|
||||
'00:00, 1 (january) 2001',
|
||||
'',
|
||||
'00:00, 1 January 2000',
|
||||
'00:00, 1 (january) 2000',
|
||||
],
|
||||
],
|
||||
'System block (type \'test\')' => [
|
||||
|
|
@ -117,13 +119,31 @@ class BlockErrorFormatterTest extends MediaWikiLangTestCase {
|
|||
'systemblockedtext',
|
||||
[
|
||||
'',
|
||||
'no reason given',
|
||||
'(proxyblockreason)',
|
||||
'1.2.3.4',
|
||||
'',
|
||||
'test',
|
||||
'infinite',
|
||||
'(infiniteblock)',
|
||||
'',
|
||||
'00:00, 1 January 2000',
|
||||
'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',
|
||||
],
|
||||
],
|
||||
'Composite block (original blocks not inserted)' => [
|
||||
|
|
@ -131,13 +151,13 @@ class BlockErrorFormatterTest extends MediaWikiLangTestCase {
|
|||
'blockedtext-composite',
|
||||
[
|
||||
'',
|
||||
'no reason given',
|
||||
'(blockednoreason)',
|
||||
'1.2.3.4',
|
||||
'',
|
||||
'Your IP address appears in multiple blacklists',
|
||||
'infinite',
|
||||
'(blockedtext-composite-no-ids)',
|
||||
'(infiniteblock)',
|
||||
'',
|
||||
'00:00, 1 January 2000',
|
||||
'00:00, 1 (january) 2000',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -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->getReason(), 'Correct block type for XFF header ' . $xff
|
||||
$exResult, $block->getReasonComment()->text, 'Correct block type for XFF header ' . $xff
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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->getReason(), $fields['Reason']['default'] );
|
||||
$this->assertSame( $block->getReasonComment()->text, $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->getReason() );
|
||||
$this->assertSame( $reason, $block->getReasonComment()->text );
|
||||
$this->assertSame( $expiry, $block->getExpiry() );
|
||||
}
|
||||
|
||||
|
|
@ -230,7 +230,7 @@ class SpecialBlockTest extends SpecialPageTestBase {
|
|||
$this->assertTrue( $result );
|
||||
|
||||
$block = DatabaseBlock::newFromTarget( $badActor );
|
||||
$this->assertSame( $reason, $block->getReason() );
|
||||
$this->assertSame( $reason, $block->getReasonComment()->text );
|
||||
$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->getReason() );
|
||||
$this->assertSame( $reason, $block->getReasonComment()->text );
|
||||
$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->getReason() );
|
||||
$this->assertSame( $reason, $block->getReasonComment()->text );
|
||||
$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->getReason() );
|
||||
$this->assertSame( $reason, $block->getReasonComment()->text );
|
||||
$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->getReason() );
|
||||
$this->assertSame( $reason, $block->getReasonComment()->text );
|
||||
$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->getReason() );
|
||||
$this->assertSame( $reason, $block->getReasonComment()->text );
|
||||
$this->assertSame( $expiry, $block->getExpiry() );
|
||||
$this->assertTrue( $block->isSitewide() );
|
||||
$this->assertCount( 0, $block->getRestrictions() );
|
||||
|
|
|
|||
Loading…
Reference in a new issue