aboutsummaryrefslogtreecommitdiffstats
path: root/includes/specials/SpecialBlock.php
diff options
context:
space:
mode:
authorTim Starling <tstarling@wikimedia.org>2023-09-18 11:32:32 +1000
committerTim Starling <tstarling@wikimedia.org>2023-09-20 09:40:52 +1000
commitcdbd39bfdf78c31903171b52a507e04512f11f20 (patch)
treea3c5f381afef1a7317ce327c638d7d191f77228c /includes/specials/SpecialBlock.php
parent30f54f632251b153729f4cbb373bc2918f263443 (diff)
downloadmediawikicore-cdbd39bfdf78c31903171b52a507e04512f11f20.tar.gz
mediawikicore-cdbd39bfdf78c31903171b52a507e04512f11f20.zip
Blocks cleanup
* Make BlockManager internal methods private, since nothing calls them anymore. * In AbstractBlock and DatabaseBlock, remove deprecated public properties mExpiry, mHideName, mTimestamp, mAuto and mParentBlockId. * In BlockRestrictionStore, remove all the "instanceof Restriction" checks. If someone passes in something that's not a Restriction, we should throw, not ignore it, because we don't know the caller's intention. Add a type declaration to $hasher in equals() so that it will throw. * Remove the "m" prefix from all private and protected properties. AbstractBlock is not stable to override so this is not a stable interface break. * In BlockRestrictionStore::restrictionsToRemove(), use an O(N) algorithm. * In BlockRestrictionStore::rowToRestriction(), use a switch instead of a type map, so that the calls are statically analyzable. * In BlockUser::__construct(), fix the initialisation order issue by inlining the relevant logic. * Rename variable $actionRestriction. * In Special:Block, fix call to deprecated method getTargetAndType(), and hard deprecate it. @deprecated has the effect of deprecating a method for both internal and external callers, there's no such thing as an external-only deprecation. So it's necessary to rename it if you want to keep it as a private method. Bug: T345683 Change-Id: If4a4a18d7b5fec825417de81302266119c215fd3
Diffstat (limited to 'includes/specials/SpecialBlock.php')
-rw-r--r--includes/specials/SpecialBlock.php19
1 files changed, 18 insertions, 1 deletions
diff --git a/includes/specials/SpecialBlock.php b/includes/specials/SpecialBlock.php
index d1b16545f375..600ea66ef81e 100644
--- a/includes/specials/SpecialBlock.php
+++ b/includes/specials/SpecialBlock.php
@@ -177,7 +177,7 @@ class SpecialBlock extends FormSpecialPage {
// need to extract *every* variable from the form just for processing here, but
// there are legitimate uses for some variables
$request = $this->getRequest();
- [ $this->target, $this->type ] = self::getTargetAndType( $par, $request );
+ [ $this->target, $this->type ] = self::getTargetAndTypeInternal( $par, $request );
if ( $this->target instanceof UserIdentity ) {
// Set the 'relevant user' in the skin, so it displays links like Contributions,
// User logs, UserRights, etc.
@@ -737,6 +737,7 @@ class SpecialBlock extends FormSpecialPage {
* prioritized, since it matches the HTML form.
*
* @deprecated since 1.36. Use BlockUtils::parseBlockTarget directly instead.
+ * Hard-deprecated since 1.41.
*
* @param string|null $par Subpage parameter passed to setup, or data value from
* the HTMLForm
@@ -745,6 +746,22 @@ class SpecialBlock extends FormSpecialPage {
* @phan-return array{0:UserIdentity|string|null,1:int|null}
*/
public static function getTargetAndType( ?string $par, WebRequest $request = null ) {
+ wfDeprecated( __METHOD__, '1.36' );
+ return self::getTargetAndTypeInternal( $par, $request );
+ }
+
+ /**
+ * Get the target and type, given the request and the subpage parameter.
+ * Several parameters are handled for backwards compatability. 'wpTarget' is
+ * prioritized, since it matches the HTML form.
+ *
+ * @param string|null $par Subpage parameter passed to setup, or data value from
+ * the HTMLForm
+ * @param WebRequest|null $request Optionally try and get data from a request too
+ * @return array [ UserIdentity|string|null, DatabaseBlock::TYPE_ constant|null ]
+ * @phan-return array{0:UserIdentity|string|null,1:int|null}
+ */
+ private static function getTargetAndTypeInternal( ?string $par, WebRequest $request = null ) {
if ( !$request instanceof WebRequest ) {
return MediaWikiServices::getInstance()->getBlockUtils()->parseBlockTarget( $par );
}