Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F585139
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/RELEASE-NOTES-1.44 b/RELEASE-NOTES-1.44
index ec6473f1e78..11485fdac5e 100644
--- a/RELEASE-NOTES-1.44
+++ b/RELEASE-NOTES-1.44
@@ -664,6 +664,11 @@ because of Phabricator reports.
- Xml::check() – use Html::check() instead
* BlockUtils and BlockUtilsFactory is now deprecated. Use BlockTargetFactory
and CrossWikiBlockTargetFactory.
+* Passing a string or UserIdentity object to DatabaseBlock::setTarget() or
+ the 'address' parameter to DatabaseBlock::__construct() is now deprecated
+ and will emit deprecation warnings. Use BlockTargetFactory to obtain a
+ BlockTarget to pass to the 'target' parameter of these functions, or use
+ DatabaseBlockStore::newUnsaved() or ::insertBlockWithParams(). (T385966)
* RenameuserSQL::rename has been deprecated and should be replaced with
RenameuserSQL::renameUser, which returns a Status instead of boolean.
* LocalFile::getQueryInfo() and OldLocalFile::getQueryInfo(), deprecated
diff --git a/includes/block/AbstractBlock.php b/includes/block/AbstractBlock.php
index 667a5bd586c..8e7de5fede0 100644
--- a/includes/block/AbstractBlock.php
+++ b/includes/block/AbstractBlock.php
@@ -76,8 +76,7 @@ abstract class AbstractBlock implements Block {
*
* @param array $options Parameters of the block, with supported options:
* - target: (BlockTarget) The target object (since 1.44)
- * - address: (string|UserIdentity) Target user name, user identity object,
- * IP address or IP range.
+ * - address: (string|UserIdentity) Deprecated since 1.44, use 'target'.
* - wiki: (string|false) The wiki the block has been issued in,
* self::LOCAL for the local wiki (since 1.38)
* - reason: (string|Message|CommentStoreComment) Reason for the block
@@ -107,6 +106,9 @@ abstract class AbstractBlock implements Block {
}
$this->setTarget( $options['target'] );
} elseif ( isset( $options['address'] ) ) {
+ wfDeprecatedMsg(
+ 'The address parameter to AbstractBlock::__construct is deprecated since 1.44',
+ '1.44' );
$this->setTarget( $options['address'] );
} else {
$this->setTarget( null );
@@ -407,7 +409,8 @@ abstract class AbstractBlock implements Block {
/**
* Set the target for this block
- * @param BlockTarget|string|UserIdentity|null $target
+ * @param BlockTarget|string|UserIdentity|null $target Passing UserIdentity|string is deprecated
+ * since 1.44. Set the target by passing BlockTarget|null.
*/
public function setTarget( $target ) {
// Small optimization to make this code testable, this is what would happen anyway
@@ -417,6 +420,10 @@ abstract class AbstractBlock implements Block {
$this->assertWiki( $target->getWikiId() );
$this->target = $target;
} else {
+ wfDeprecatedMsg(
+ 'Passing UserIdentity|string to AbstractBlock::setTarget is deprecated since 1.44',
+ '1.44'
+ );
$parsedTarget = MediaWikiServices::getInstance()
->getCrossWikiBlockTargetFactory()
->getFactory( $this->wikiId )
diff --git a/includes/block/BlockManager.php b/includes/block/BlockManager.php
index 817374a46e8..8a400c49013 100644
--- a/includes/block/BlockManager.php
+++ b/includes/block/BlockManager.php
@@ -361,7 +361,8 @@ class BlockManager {
return $blocks[ 0 ];
} else {
$compositeBlock = CompositeBlock::createFromBlocks( ...$blocks );
- $compositeBlock->setTarget( $ip );
+ $target = $ip === null ? null : $this->blockTargetFactory->newAnonIpBlockTarget( $ip );
+ $compositeBlock->setTarget( $target );
return $compositeBlock;
}
}
diff --git a/tests/phpunit/includes/block/DatabaseBlockTest.php b/tests/phpunit/includes/block/DatabaseBlockTest.php
index f56ce8eb4bf..e1a1b8af150 100644
--- a/tests/phpunit/includes/block/DatabaseBlockTest.php
+++ b/tests/phpunit/includes/block/DatabaseBlockTest.php
@@ -272,7 +272,8 @@ class DatabaseBlockTest extends MediaWikiLangTestCase {
'sitewide' => true,
] );
- $block->setTarget( new UserIdentityValue( $user->getId(), $user->getName() ) );
+ $block->setTarget(
+ new UserBlockTarget( new UserIdentityValue( $user->getId(), $user->getName() ) ) );
$block->setBlocker( $this->getTestSysop()->getUser() );
$blockStore = $this->getServiceContainer()->getDatabaseBlockStore();
@@ -299,7 +300,7 @@ class DatabaseBlockTest extends MediaWikiLangTestCase {
'sitewide' => false,
] );
- $block->setTarget( $user );
+ $block->setTarget( new UserBlockTarget( $user ) );
$block->setBlocker( $this->getTestSysop()->getUser() );
$blockStore = $this->getServiceContainer()->getDatabaseBlockStore();
@@ -331,7 +332,7 @@ class DatabaseBlockTest extends MediaWikiLangTestCase {
'sitewide' => true,
] );
- $block->setTarget( $user );
+ $block->setTarget( new UserBlockTarget( $user ) );
$block->setBlocker( $this->getTestSysop()->getUser() );
$blockStore = $this->getServiceContainer()->getDatabaseBlockStore();
@@ -356,7 +357,7 @@ class DatabaseBlockTest extends MediaWikiLangTestCase {
'sitewide' => false,
] );
- $block->setTarget( $user );
+ $block->setTarget( new UserBlockTarget( $user ) );
$block->setBlocker( $this->getTestSysop()->getUser() );
$blockStore = $this->getServiceContainer()->getDatabaseBlockStore();
@@ -385,7 +386,7 @@ class DatabaseBlockTest extends MediaWikiLangTestCase {
'sitewide' => false,
] );
- $block->setTarget( $user );
+ $block->setTarget( new UserBlockTarget( $user ) );
$block->setBlocker( $this->getTestSysop()->getUser() );
$blockStore = $this->getServiceContainer()->getDatabaseBlockStore();
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Jul 5, 5:32 AM (11 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
227555
Default Alt Text
(5 KB)
Attached To
Mode
rMW mediawiki
Attached
Detach File
Event Timeline
Log In to Comment