Cleanup hard-deprecated code in blocks.

Change-Id: I1b3f4a0f072197c6b3dc6c9a80fcb2946aeb6360
This commit is contained in:
Petr Pchelko 2021-09-29 08:51:33 -07:00
parent cf81b18f25
commit 25bb5b296a
4 changed files with 9 additions and 97 deletions

View file

@ -167,14 +167,15 @@ because of Phabricator reports.
since 1.37, has been removed.
* Parser::$mStripState, deprecated in 1.35, has been made private. Use
Parser::getStripState() instead.
* DatabaseBlock::setBlocker() no longer accepts a username as blocker, it
must always be a UserIdentity. This was deprecated since 1.36.
* The following deprecated constructor options of DatabaseBlock class
have been removed:
- 'byText' property with blocker's name,
use 'by' property with UserIdentity value instead.
- 'by' property with blocker's ID,
use 'by' property with UserIdentity value instead.
* The following deprecated features in blocks were removed:
- DatabaseBlock constructor 'byText' property with blocker's name, use 'by'
property with UserIdentity value instead.
- DatabaseBlock constructor 'by' property with blocker's ID, use 'by' property
with UserIdentity value instead.
- DatabaseBlock::isWhitelistedFromAutoblocks, use ::isExemptedFromAutoblocks.
- DatabaseBlock::setBlocker now only accepts UserIdentity.
- AbstractBlock::getTargetAndType and ::getTarget, use ::getTargetName,
::getTargetUserIdentity and ::getType instead
* The following functions, emitting deprecations since 1.37, have been removed:
- Title::isWatchable()
- WatchAction::doWatchOrUnwatch(), WatchAction::doWatch(),

View file

@ -307,43 +307,6 @@ abstract class AbstractBlock implements Block {
return $this->type;
}
/**
* Get the target and target type for this particular block. Note that for autoblocks,
* this returns the unredacted name; frontend functions need to call $block->getRedactedName()
* in this situation.
*
* If the type is not null, it will be an AbstractBlock::TYPE_ constant.
*
* @deprecated since 1.37, use getTargetName() and getTargetUserIdentity()
* together with getType()
*
* @return array [ User|String|null, int|null ]
* @todo FIXME: This should be an integral part of the block member variables
*/
public function getTargetAndType() {
wfDeprecated( __METHOD__, '1.37' );
return [ $this->getTarget(), $this->getType() ];
}
/**
* Get the target for this particular block. Note that for autoblocks,
* this returns the unredacted name; frontend functions need to call $block->getRedactedName()
* in this situation.
* @deprecated since 1.37, use getTargetName() and getTargetUserIdentity()
* together with getType()
* @return User|string|null
*/
public function getTarget() {
wfDeprecated( __METHOD__, '1.37' );
if ( $this->target instanceof UserIdentity ) {
return MediaWikiServices::getInstance()
->getUserFactory()
->newFromUserIdentity( $this->target );
} else {
return $this->target;
}
}
/**
* @since 1.37
* @return ?UserIdentity

View file

@ -512,20 +512,6 @@ class DatabaseBlock extends AbstractBlock {
->updateBlock( $this );
}
/**
* Checks whether a given IP is on the autoblock exemption list.
*
* @deprecated since 1.36; use DatabaseBlock::isExemptedFromAutoblocks()
*
* @param string $ip The IP to check
* @return bool
*/
public static function isWhitelistedFromAutoblocks( $ip ) {
// Hard-deprecated since MW 1.37.
wfDeprecated( __METHOD__, '1.36' );
return self::isExemptedFromAutoblocks( $ip );
}
/**
* Checks whether a given IP is on the autoblock exemption list.
* TODO: this probably belongs somewhere else, but not sure where...

View file

@ -1,38 +0,0 @@
<?php
namespace MediaWiki\Tests\Unit\Block;
use MediaWiki\Block\AbstractBlock;
use MediaWikiUnitTestCase;
/**
* @group Blocking
* @coversDefaultClass MediaWiki\Block\AbstractBlock
*/
class AbstractBlockTest extends MediaWikiUnitTestCase {
/**
* @covers ::getTarget
*/
public function testGetTarget_deprecated() {
$this->expectDeprecation();
$block = $this->createNoOpAbstractMock(
AbstractBlock::class,
[ 'getTarget' ]
);
$block->getTarget();
}
/**
* @covers ::getTargetAndType
*/
public function testGetTargetAndType_deprecated() {
$this->expectDeprecation();
$this->expectDeprecationMessageMatches( '/AbstractBlock::getTargetAndType was deprecated in MediaWiki 1.37/' );
$block = $this->createNoOpAbstractMock(
AbstractBlock::class,
[ 'getTargetAndType' ]
);
$block->getTargetAndType();
}
}