},
'BlockManager' => function ( MediaWikiServices $services ) : BlockManager {
- $config = $services->getMainConfig();
$context = RequestContext::getMain();
return new BlockManager(
new ServiceOptions(
return $maxExpiry;
}
+ /**
+ * Get the IDs for the original blocks, ignoring any that are null
+ *
+ * @return int[]
+ */
+ protected function getIds() {
+ $ids = [];
+ foreach ( $this->originalBlocks as $block ) {
+ $id = $block->getId();
+ if ( $id !== null ) {
+ $ids[] = $id;
+ }
+ }
+ return $ids;
+ }
+
/**
* @inheritDoc
*/
public function getPermissionsError( IContextSource $context ) {
$params = $this->getBlockErrorParams( $context );
+ $ids = implode( ', ', array_map( function ( $id ) {
+ return '#' . $id;
+ }, $this->getIds() ) );
+ if ( $ids === '' ) {
+ $idsMsg = $context->msg( 'blockedtext-composite-no-ids' )->plain();
+ } else {
+ $idsMsg = $context->msg( 'blockedtext-composite-ids', [ $ids ] )->plain();
+ }
+
+ // TODO: Clean up error messages params so we don't have to do this (T227174)
+ $params[ 4 ] = $idsMsg;
+
$msg = 'blockedtext-composite';
array_unshift( $params, $msg );
*/
public function getPermissionsError( IContextSource $context ) {
$params = $this->getBlockErrorParams( $context );
- // TODO: Clean up error messages params so we don't have to do this
+
+ // TODO: Clean up error messages params so we don't have to do this (T227174)
$params[ 4 ] = $this->getSystemBlockType();
$msg = 'systemblockedtext';
"autoblockedtext": "Your IP address has been automatically blocked because it was used by another user, who was blocked by $1.\nThe reason given is:\n\n:<em>$2</em>\n\n* Start of block: $8\n* Expiration of block: $6\n* Intended blockee: $7\n\nYou may contact $1 or one of the other [[{{MediaWiki:Grouppage-sysop}}|administrators]] to discuss the block.\n\nNote that you may not use the \"{{int:emailuser}}\" feature unless you have a valid email address registered in your [[Special:Preferences|user preferences]] and you have not been blocked from using it.\n\nYour current IP address is $3, and the block ID is #$5.\nPlease include all above details in any queries you make.",
"systemblockedtext": "Your username or IP address has been automatically blocked by MediaWiki.\nThe reason given is:\n\n:<em>$2</em>\n\n* Start of block: $8\n* Expiration of block: $6\n* Intended blockee: $7\n\nYour current IP address is $3.\nPlease include all above details in any queries you make.",
"blockednoreason": "no reason given",
- "blockedtext-composite": "<strong>Your username or IP address has been blocked.</strong>\n\nThe reason given is:\n\n:<em>$2</em>.\n\n* Start of block: $8\n* Expiration of longest block: $6\n\nYour current IP address is $3.\nPlease include all above details in any queries you make.",
+ "blockedtext-composite": "<strong>Your username or IP address has been blocked.</strong>\n\nThe reason given is:\n\n:<em>$2</em>.\n\n* Start of block: $8\n* Expiration of longest block: $6\n\n* $5\n\nYour current IP address is $3.\nPlease include all above details in any queries you make.",
+ "blockedtext-composite-ids": "Relevant block IDs: $1 (your IP address may also be blacklisted)",
+ "blockedtext-composite-no-ids": "Your IP address appears in multiple blacklists",
"blockedtext-composite-reason": "There are multiple blocks against your account and/or IP address",
"whitelistedittext": "Please $1 to edit pages.",
"confirmedittext": "You must confirm your email address before editing pages.\nPlease set and validate your email address through your [[Special:Preferences|user preferences]].",
"autoblockedtext": "Text displayed to automatically blocked users.\n\n\"email this user\" should be consistent with {{msg-mw|Emailuser}}.\n\nParameters:\n* $1 - the blocking sysop (with a link to his/her userpage)\n* $2 - the reason for the block (in case of autoblocks: {{msg-mw|autoblocker}})\n* $3 - the current IP address of the blocked user\n* $4 - (Unused) the blocking sysop's username (plain text, without the link). Use it for GENDER.\n* $5 - the unique numeric identifier of the applied autoblock\n* $6 - the expiry of the block\n* $7 - the intended target of the block (what the blocking user specified in the blocking form)\n* $8 - the timestamp when the block started\nSee also:\n* {{msg-mw|Grouppage-sysop}}\n* {{msg-mw|Blockedtext|notext=1}}\n* {{msg-mw|Systemblockedtext|notext=1}}",
"systemblockedtext": "Text displayed to requests blocked by MediaWiki configuration.\n\n\"email this user\" should be consistent with {{msg-mw|Emailuser}}.\n\nParameters:\n* $1 - (Unused) A dummy user attributed as the blocker, possibly as a link to a user page.\n* $2 - the reason for the block\n* $3 - the current IP address of the blocked user\n* $4 - (Unused) the dummy blocking user's username (plain text, without the link).\n* $5 - A short string indicating the type of system block.\n* $6 - the expiry of the block\n* $7 - the intended target of the block\n* $8 - the timestamp when the block started\nSee also:\n* {{msg-mw|Grouppage-sysop}}\n* {{msg-mw|Blockedtext|notext=1}}\n* {{msg-mw|Autoblockedtext|notext=1}}",
"blockednoreason": "Substituted with <code>$2</code> in the following message if the reason is not given:\n* {{msg-mw|cantcreateaccount-text}}.\n{{Identical|No reason given}}",
- "blockedtext-composite": "Text displayed to requests blocked by more than one block.\n\n\"email this user\" should be consistent with {{msg-mw|Emailuser}}.\n\nParameters:\n* $1 - (Unused) A dummy user attributed as the blocker, possibly as a link to a user page.\n* $2 - the reason for the block\n* $3 - the current IP address of the blocked user\n* $4 - (Unused) the dummy blocking user's username (plain text, without the link).\n* $5 - (Unused) placeholder for the block ID.\n* $6 - the expiry of the block with the longest duration\n* $7 - (Unused) the intended target of the block\n* $8 - the timestamp when the block started\nSee also:\n* {{msg-mw|Systemblockedtext|notext=1}}",
+ "blockedtext-composite": "Text displayed to requests blocked by more than one block.\n\n\"email this user\" should be consistent with {{msg-mw|Emailuser}}.\n\nParameters:\n* $1 - (Unused) A dummy user attributed as the blocker, possibly as a link to a user page.\n* $2 - the reason for the block\n* $3 - the current IP address of the blocked user\n* $4 - (Unused) the dummy blocking user's username (plain text, without the link).\n* $5 - details of the individual blocks that this block is made from\n* $6 - the expiry of the block with the longest duration\n* $7 - (Unused) the intended target of the block\n* $8 - the timestamp when the block started\nSee also:\n* {{msg-mw|Systemblockedtext|notext=1}}",
+ "blockedtext-composite-ids": "Text displayed when a user is blocked by multiple blocks, if at least one block comes from the database.\n\nParameters:\n* $1 - IDs of the blocks from the database",
+ "blockedtext-composite-no-ids": "Text displayed when a user is blocked by multiple blocks, if all the blocks are due to the IP being blacklisted.",
"blockedtext-composite-reason": "Reason given to blocked users who are affected by more than one block.\n\nSee also:\n* {{msg-mw|blockedtext-composite}}",
"whitelistedittext": "Used as error message. Parameters:\n* $1 - a link to [[Special:UserLogin]] with {{msg-mw|loginreqlink}} as link description\n* $2 - an URL to the same\n\nSee also:\n* {{msg-mw|Nocreatetext}}\n* {{msg-mw|Uploadnologintext}}\n* {{msg-mw|Loginreqpagetext}}",
"confirmedittext": "Used as error message.",
'Badtitle' => [ '잘못된제목', '인식불가제목', '잘못된이름', '인식불가이름' ],
'Blankpage' => [ '빈문서' ],
'Block' => [ '차단', 'IP차단', '사용자차단' ],
+ 'BlockList' => [ '차단목록', 'IP차단목록', '차단된사용자' ],
'Booksources' => [ '책찾기' ],
'BotPasswords' => [ '봇비밀번호' ],
'BrokenRedirects' => [ '끊긴넘겨주기' ],
'Import' => [ '가져오기' ],
'Invalidateemail' => [ '이메일인증취소', '이메일인증해제' ],
'JavaScriptTest' => [ '자바스크립트시험', '자바스크립트테스트' ],
- 'BlockList' => [ '차단목록', 'IP차단목록', '차단된사용자' ],
'LinkSearch' => [ '링크검색', '링크찾기' ],
'Listadmins' => [ '관리자목록', '관리자' ],
'Listbots' => [ '봇목록', '봇' ],
'Mostlinkedtemplates' => [ '많이쓰는틀' ],
'Mostrevisions' => [ '역사긴문서' ],
'Movepage' => [ '이동', '문서이동', '옮기기', '문서옮기기' ],
+ 'Mute' => [ '뮤트' ],
'Mycontributions' => [ '내기여', '내기여목록' ],
'MyLanguage' => [ '내언어' ],
'Mypage' => [ '내사용자문서' ],
];
}
+ /**
+ * @covers ::getPermissionsError
+ * @dataProvider provideGetPermissionsError
+ */
+ public function testGetPermissionsError( $ids, $expectedIdsMsg ) {
+ // Some block options
+ $timestamp = time();
+ $target = '1.2.3.4';
+ $byText = 'MediaWiki default';
+ $formattedByText = "\u{202A}{$byText}\u{202C}";
+ $reason = '';
+ $expiry = 'infinite';
+
+ $block = $this->getMockBuilder( CompositeBlock::class )
+ ->setMethods( [ 'getIds', 'getBlockErrorParams' ] )
+ ->getMock();
+ $block->method( 'getIds' )
+ ->willReturn( $ids );
+ $block->method( 'getBlockErrorParams' )
+ ->willReturn( [
+ $formattedByText,
+ $reason,
+ $target,
+ $formattedByText,
+ null,
+ $timestamp,
+ $target,
+ $expiry,
+ ] );
+
+ $this->assertSame( [
+ 'blockedtext-composite',
+ $formattedByText,
+ $reason,
+ $target,
+ $formattedByText,
+ $expectedIdsMsg,
+ $timestamp,
+ $target,
+ $expiry,
+ ], $block->getPermissionsError( RequestContext::getMain() ) );
+ }
+
+ public static function provideGetPermissionsError() {
+ return [
+ 'All original blocks are system blocks' => [
+ [],
+ 'Your IP address appears in multiple blacklists',
+ ],
+ 'One original block is a database block' => [
+ [ 100 ],
+ 'Relevant block IDs: #100 (your IP address may also be blacklisted)',
+ ],
+ 'Several original blocks are database blocks' => [
+ [ 100, 101, 102 ],
+ 'Relevant block IDs: #100, #101, #102 (your IP address may also be blacklisted)',
+ ],
+ ];
+ }
+
/**
* Get an instance of BlockRestrictionStore
*