aboutsummaryrefslogtreecommitdiffstats
path: root/includes/MediaWikiServices.php
diff options
context:
space:
mode:
authorTim Starling <tstarling@wikimedia.org>2025-01-15 15:25:49 +1100
committerTim Starling <tstarling@wikimedia.org>2025-02-19 11:18:41 +1100
commitc0dd3afe639260f05b89db1e1191adba9e22ac46 (patch)
treef012264484f33b826e8fe577629591483f967e9a /includes/MediaWikiServices.php
parent8210d146e1ac8fa22586bf8412df39059631efa2 (diff)
downloadmediawikicore-c0dd3afe639260f05b89db1e1191adba9e22ac46.tar.gz
mediawikicore-c0dd3afe639260f05b89db1e1191adba9e22ac46.zip
block: Add a BlockTarget class hierarchy
Main change: * Add a class hierarchy representing block targets, representing a target and type. * Add BlockTargetFactory, replacing BlockUtils. * Add CrossWikiBlockTargetFactory, replacing BlockUtilsFactory. * Construct a BlockTarget object early in the request flow and pass it down through the layers, instead of having every layer interpret UserIdentity|string target specifications. Also: * Remove Block::TYPE_ID. Nothing uses it in code search, so there's no point in porting it to the new system. * Stop using the type constants as specificity scores. Add BlockTarget::getSpecificity(). * Add DatabaseBlockStore::newUnsaved() to replace direct construction of DatabaseBlock in insertBlock() callers. There are many such callers in tests. This is part of the effort to remove the service container usage in DatabaseBlock::__construct(). * Make DatabaseBlock::getRangeStart() and getRangeEnd() return null if the block is not a range, since that is convenient for their only caller following the resolution of T51504. * Add DatabaseBlock::getIpHex() which similarly maps to a DB field in the new schema. * In ApiBlock and ApiUnblock, have ParamValidator provide UserIdentity objects instead of converting to a string and back to a UserIdentity again. Bug: T382106 Change-Id: I2ce1a82f3fbb3cf18aa2d17986d46dbdcc70c761
Diffstat (limited to 'includes/MediaWikiServices.php')
-rw-r--r--includes/MediaWikiServices.php18
1 files changed, 18 insertions, 0 deletions
diff --git a/includes/MediaWikiServices.php b/includes/MediaWikiServices.php
index df8dc7beb039..448aa6d0715b 100644
--- a/includes/MediaWikiServices.php
+++ b/includes/MediaWikiServices.php
@@ -38,9 +38,11 @@ use MediaWiki\Block\BlockManager;
use MediaWiki\Block\BlockPermissionCheckerFactory;
use MediaWiki\Block\BlockRestrictionStore;
use MediaWiki\Block\BlockRestrictionStoreFactory;
+use MediaWiki\Block\BlockTargetFactory;
use MediaWiki\Block\BlockUserFactory;
use MediaWiki\Block\BlockUtils;
use MediaWiki\Block\BlockUtilsFactory;
+use MediaWiki\Block\CrossWikiBlockTargetFactory;
use MediaWiki\Block\DatabaseBlockStore;
use MediaWiki\Block\DatabaseBlockStoreFactory;
use MediaWiki\Block\HideUserUtils;
@@ -829,6 +831,13 @@ class MediaWikiServices extends ServiceContainer {
}
/**
+ * @since 1.44
+ */
+ public function getBlockTargetFactory(): BlockTargetFactory {
+ return $this->getService( 'BlockTargetFactory' );
+ }
+
+ /**
* @since 1.36
*/
public function getBlockUserFactory(): BlockUserFactory {
@@ -836,6 +845,7 @@ class MediaWikiServices extends ServiceContainer {
}
/**
+ * @deprecated since 1.44
* @since 1.36
*/
public function getBlockUtils(): BlockUtils {
@@ -843,6 +853,7 @@ class MediaWikiServices extends ServiceContainer {
}
/**
+ * @deprecated since 1.44
* @since 1.42
*/
public function getBlockUtilsFactory(): BlockUtilsFactory {
@@ -1030,6 +1041,13 @@ class MediaWikiServices extends ServiceContainer {
}
/**
+ * @since 1.44
+ */
+ public function getCrossWikiBlockTargetFactory(): CrossWikiBlockTargetFactory {
+ return $this->getService( 'CrossWikiBlockTargetFactory' );
+ }
+
+ /**
* @since 1.36
*/
public function getDatabaseBlockStore(): DatabaseBlockStore {