Page MenuHomePhorge

No OneTemporary

Size
19 KB
Referenced Files
None
Subscribers
None
diff --git a/RELEASE-NOTES-1.44 b/RELEASE-NOTES-1.44
index 87fa91d1a22..fa4b959da1a 100644
--- a/RELEASE-NOTES-1.44
+++ b/RELEASE-NOTES-1.44
@@ -412,6 +412,9 @@ because of Phabricator reports.
marked as @internal and must not be used by extensions.
* The modules codex-search-styles and @wikimedia/codex-search have been
removed. Please use MediaWiki\\ResourceLoader\\CodexModule instead.
+* SpecialBlock::processForm(), SpecialBlock::parseExpiryInput() and
+ SpecialBlock::canBlockEmail(), deprecated in 1.36, and
+ SpecialBlock::getSuggestedDurations(), deprecated in 1.42, has been removed.
* …
=== Deprecations in 1.44 ===
diff --git a/includes/specialpage/SpecialPageFactory.php b/includes/specialpage/SpecialPageFactory.php
index c707a920945..c25d482ddcf 100644
--- a/includes/specialpage/SpecialPageFactory.php
+++ b/includes/specialpage/SpecialPageFactory.php
@@ -530,6 +530,7 @@ class SpecialPageFactory {
'TitleFormatter',
'NamespaceInfo',
'UserOptionsLookup',
+ 'WatchlistManager'
]
],
'Unblock' => [
diff --git a/includes/specials/SpecialBlock.php b/includes/specials/SpecialBlock.php
index f5cab123d14..3b9e8daeca7 100644
--- a/includes/specials/SpecialBlock.php
+++ b/includes/specials/SpecialBlock.php
@@ -27,7 +27,6 @@ use MediaWiki\Block\BlockTarget;
use MediaWiki\Block\BlockTargetFactory;
use MediaWiki\Block\BlockTargetWithIp;
use MediaWiki\Block\BlockTargetWithUserPage;
-use MediaWiki\Block\BlockUser;
use MediaWiki\Block\BlockUserFactory;
use MediaWiki\Block\DatabaseBlock;
use MediaWiki\Block\DatabaseBlockStore;
@@ -38,16 +37,12 @@ use MediaWiki\Block\Restriction\NamespaceRestriction;
use MediaWiki\Block\Restriction\PageRestriction;
use MediaWiki\Block\UserBlockTarget;
use MediaWiki\CommentStore\CommentStore;
-use MediaWiki\Context\IContextSource;
use MediaWiki\Exception\ErrorPageError;
use MediaWiki\Html\Html;
use MediaWiki\HTMLForm\HTMLForm;
-use MediaWiki\Language\Language;
use MediaWiki\Logging\LogEventsList;
use MediaWiki\MainConfigNames;
-use MediaWiki\MediaWikiServices;
use MediaWiki\Message\Message;
-use MediaWiki\Permissions\Authority;
use MediaWiki\Request\WebRequest;
use MediaWiki\SpecialPage\FormSpecialPage;
use MediaWiki\SpecialPage\SpecialPage;
@@ -57,9 +52,9 @@ use MediaWiki\Title\Title;
use MediaWiki\Title\TitleFormatter;
use MediaWiki\User\Options\UserOptionsLookup;
use MediaWiki\User\User;
-use MediaWiki\User\UserIdentity;
use MediaWiki\User\UserNamePrefixSearch;
use MediaWiki\User\UserNameUtils;
+use MediaWiki\Watchlist\WatchlistManager;
use OOUI\FieldLayout;
use OOUI\HtmlSnippet;
use OOUI\LabelWidget;
@@ -85,6 +80,7 @@ class SpecialBlock extends FormSpecialPage {
private TitleFormatter $titleFormatter;
private NamespaceInfo $namespaceInfo;
private UserOptionsLookup $userOptionsLookup;
+ private WatchlistManager $watchlistManager;
/** @var BlockTarget|null User to be blocked, as passed either by parameter
* (url?wpTarget=Foo) or as subpage (Special:Block/Foo)
@@ -123,7 +119,8 @@ class SpecialBlock extends FormSpecialPage {
BlockActionInfo $blockActionInfo,
TitleFormatter $titleFormatter,
NamespaceInfo $namespaceInfo,
- UserOptionsLookup $userOptionsLookup
+ UserOptionsLookup $userOptionsLookup,
+ WatchlistManager $watchlistManager
) {
parent::__construct( 'Block', 'block' );
@@ -137,6 +134,7 @@ class SpecialBlock extends FormSpecialPage {
$this->titleFormatter = $titleFormatter;
$this->namespaceInfo = $namespaceInfo;
$this->userOptionsLookup = $userOptionsLookup;
+ $this->watchlistManager = $watchlistManager;
$this->useCodex = $this->getConfig()->get( MainConfigNames::UseCodexSpecialBlock ) ||
$this->getRequest()->getBool( 'usecodex' );
$this->useMultiblocks = $this->getConfig()->get( MainConfigNames::EnableMultiBlocks ) ||
@@ -998,44 +996,20 @@ class SpecialBlock extends FormSpecialPage {
}
/**
- * Given the form data, actually implement a block.
- *
- * @deprecated since 1.36, use BlockUserFactory service instead,
- * hard-deprecated since 1.43
- * @param array $data
- * @param IContextSource $context
- * @return bool|string|array|Status
- */
- public static function processForm( array $data, IContextSource $context ) {
- wfDeprecated( __METHOD__, '1.36' );
- $services = MediaWikiServices::getInstance();
- return self::processFormInternal(
- $data,
- $context->getAuthority(),
- $services->getBlockUserFactory(),
- $services->getBlockTargetFactory()
- );
- }
-
- /**
- * Implementation details for processForm
- * Own function to allow sharing the deprecated code with non-deprecated and service code
- *
+ * Process the form on POST submission.
* @param array $data
- * @param Authority $performer
- * @param BlockUserFactory $blockUserFactory
- * @param BlockTargetFactory $blockTargetFactory
- * @return bool|string|array|Status
+ * @param HTMLForm|null $form
+ * @return bool|string|array|Status As documented for HTMLForm::trySubmit.
*/
- private static function processFormInternal(
- array $data,
- Authority $performer,
- BlockUserFactory $blockUserFactory,
- BlockTargetFactory $blockTargetFactory
- ) {
+ public function onSubmit( array $data, ?HTMLForm $form = null ) {
+ if ( $this->useCodex ) {
+ // Treat as no submission for the JS-only Codex form.
+ // This happens if the form is submitted before any JS is loaded.
+ return false;
+ }
// Temporarily access service container until the feature flag is removed: T280532
- $enablePartialActionBlocks = MediaWikiServices::getInstance()
- ->getMainConfig()->get( MainConfigNames::EnablePartialActionBlocks );
+ $enablePartialActionBlocks = $this->getConfig()
+ ->get( MainConfigNames::EnablePartialActionBlocks );
$isPartialBlock = isset( $data['EditingRestriction'] ) &&
$data['EditingRestriction'] === 'partial';
@@ -1051,7 +1025,7 @@ class SpecialBlock extends FormSpecialPage {
}
/** @var User $target */
- $target = $blockTargetFactory->newFromString( $data['Target'] );
+ $target = $this->blockTargetFactory->newFromString( $data['Target'] );
if ( $target instanceof UserBlockTarget ) {
// Give admins a heads-up before they go and block themselves. Much messier
// to do this for IPs, but it's pretty unlikely they'd ever get the 'block'
@@ -1060,7 +1034,7 @@ class SpecialBlock extends FormSpecialPage {
// since both $data['PreviousTarget'] and $target are normalized
// but $data['Target'] gets overridden by (non-normalized) request variable
// from previous request.
- if ( $target->toString() === $performer->getUser()->getName() &&
+ if ( $target->toString() === $this->getUser()->getName() &&
( $data['PreviousTarget'] !== $target->toString() || !$data['Confirm'] )
) {
return [ 'ipb-blockingself', 'ipb-confirmaction' ];
@@ -1124,9 +1098,9 @@ class SpecialBlock extends FormSpecialPage {
$blockOptions['isEmailBlocked'] = $data['DisableEmail'];
}
- $blockUser = $blockUserFactory->newBlockUser(
+ $blockUser = $this->blockUserFactory->newBlockUser(
$target,
- $performer,
+ $this->getAuthority(),
$data['Expiry'],
$blockReason,
$blockOptions,
@@ -1164,8 +1138,8 @@ class SpecialBlock extends FormSpecialPage {
&& array_key_exists( 'Watch', $data )
&& $data['Watch']
) {
- MediaWikiServices::getInstance()->getWatchlistManager()->addWatchIgnoringRights(
- $performer->getUser(),
+ $this->watchlistManager->addWatchIgnoringRights(
+ $this->getUser(),
Title::newFromPageReference( $target->getUserPage() )
);
}
@@ -1173,75 +1147,6 @@ class SpecialBlock extends FormSpecialPage {
return true;
}
- /**
- * Get an array of suggested block durations from MediaWiki:Ipboptions
- * @todo FIXME: This uses a rather odd syntax for the options, should it be converted
- * to the standard "**<duration>|<displayname>" format?
- * @deprecated since 1.42, use Language::getBlockDurations() instead,
- * hard-deprecated since 1.43
- * @param Language|null $lang The language to get the durations in, or null to use
- * the wiki's content language
- * @param bool $includeOther Whether to include the 'other' option in the list of
- * suggestions
- * @return string[]
- */
- public static function getSuggestedDurations( ?Language $lang = null, $includeOther = true ) {
- wfDeprecated( __METHOD__, '1.42' );
- $lang ??= MediaWikiServices::getInstance()->getContentLanguage();
- return $lang->getBlockDurations( $includeOther );
- }
-
- /**
- * Convert a submitted expiry time, which may be relative ("2 weeks", etc) or absolute
- * ("24 May 2034", etc), into an absolute timestamp we can put into the database.
- *
- * @deprecated since 1.36, use BlockUser::parseExpiryInput instead,
- * hard-deprecated since 1.43
- *
- * @param string $expiry Whatever was typed into the form
- * @return string|bool Timestamp or 'infinity' or false on error.
- */
- public static function parseExpiryInput( $expiry ) {
- wfDeprecated( __METHOD__, '1.36' );
- return BlockUser::parseExpiryInput( $expiry );
- }
-
- /**
- * Can we do an email block?
- *
- * @deprecated since 1.36, use BlockPermissionChecker service instead,
- * hard-deprecated since 1.43
- * @param UserIdentity $user The sysop wanting to make a block
- * @return bool
- */
- public static function canBlockEmail( UserIdentity $user ) {
- wfDeprecated( __METHOD__, '1.36' );
- return MediaWikiServices::getInstance()
- ->getBlockPermissionCheckerFactory()
- ->newChecker( User::newFromIdentity( $user ) )
- ->checkEmailPermissions();
- }
-
- /**
- * Process the form on POST submission.
- * @param array $data
- * @param HTMLForm|null $form
- * @return bool|string|array|Status As documented for HTMLForm::trySubmit.
- */
- public function onSubmit( array $data, ?HTMLForm $form = null ) {
- if ( $this->useCodex ) {
- // Treat as no submission for the JS-only Codex form.
- // This happens if the form is submitted before any JS is loaded.
- return false;
- }
- return self::processFormInternal(
- $data,
- $this->getAuthority(),
- $this->blockUserFactory,
- $this->blockTargetFactory
- );
- }
-
/**
* Do something exciting on successful processing of the form, most likely to show a
* confirmation message
diff --git a/tests/phpunit/includes/specials/SpecialBlockTest.php b/tests/phpunit/includes/specials/SpecialBlockTest.php
index 4e52d3ce317..0e4c476a056 100644
--- a/tests/phpunit/includes/specials/SpecialBlockTest.php
+++ b/tests/phpunit/includes/specials/SpecialBlockTest.php
@@ -224,15 +224,15 @@ class SpecialBlockTest extends SpecialPageTestBase {
}
/**
- * @covers ::processForm
+ * @covers ::onSubmit
*/
public function testProcessForm() {
- $this->hideDeprecated( SpecialBlock::class . '::processForm' );
$badActor = $this->getTestUser()->getUserIdentity();
$context = RequestContext::getMain();
$context->setUser( $this->getTestSysop()->getUser() );
$page = $this->newSpecialPage();
+ $page->setContext( $context );
$reason = 'test';
$expiry = 'infinity';
$data = [
@@ -250,7 +250,7 @@ class SpecialBlockTest extends SpecialPageTestBase {
'HideUser' => '0',
'Watch' => '0',
];
- $result = $page->processForm( $data, $context );
+ $result = $page->onSubmit( $data );
$this->assertTrue( $result );
@@ -260,10 +260,9 @@ class SpecialBlockTest extends SpecialPageTestBase {
}
/**
- * @covers ::processForm
+ * @covers ::onSubmit
*/
public function testProcessFormExisting() {
- $this->hideDeprecated( SpecialBlock::class . '::processForm' );
$badActor = $this->getTestUser()->getUser();
$sysop = $this->getTestSysop()->getUser();
$context = RequestContext::getMain();
@@ -279,6 +278,7 @@ class SpecialBlockTest extends SpecialPageTestBase {
] );
$page = $this->newSpecialPage();
+ $page->setContext( $context );
$reason = 'test';
$expiry = 'infinity';
$data = [
@@ -296,7 +296,7 @@ class SpecialBlockTest extends SpecialPageTestBase {
'HideUser' => '0',
'Watch' => '0',
];
- $result = $page->processForm( $data, $context );
+ $result = $page->onSubmit( $data );
$this->assertTrue( $result );
@@ -307,10 +307,9 @@ class SpecialBlockTest extends SpecialPageTestBase {
}
/**
- * @covers ::processForm
+ * @covers ::onSubmit
*/
public function testProcessFormRestrictions() {
- $this->hideDeprecated( SpecialBlock::class . '::processForm' );
$this->overrideConfigValue( MainConfigNames::EnablePartialActionBlocks, true );
$badActor = $this->getTestUser()->getUser();
@@ -327,6 +326,7 @@ class SpecialBlockTest extends SpecialPageTestBase {
];
$page = $this->newSpecialPage();
+ $page->setContext( $context );
$reason = 'test';
$expiry = 'infinity';
$data = [
@@ -348,7 +348,7 @@ class SpecialBlockTest extends SpecialPageTestBase {
'NamespaceRestrictions' => '',
'ActionRestrictions' => [ $actionId ],
];
- $result = $page->processForm( $data, $context );
+ $result = $page->onSubmit( $data );
$this->assertTrue( $result );
@@ -364,10 +364,9 @@ class SpecialBlockTest extends SpecialPageTestBase {
}
/**
- * @covers ::processForm
+ * @covers ::onSubmit
*/
public function testProcessFormRestrictionsChange() {
- $this->hideDeprecated( SpecialBlock::class . '::processForm' );
$badActor = $this->getTestUser()->getUser();
$context = RequestContext::getMain();
$context->setUser( $this->getTestSysop()->getUser() );
@@ -382,6 +381,7 @@ class SpecialBlockTest extends SpecialPageTestBase {
// Create a partial block.
$page = $this->newSpecialPage();
+ $page->setContext( $context );
$reason = 'test';
$expiry = 'infinity';
$data = [
@@ -402,7 +402,7 @@ class SpecialBlockTest extends SpecialPageTestBase {
'PageRestrictions' => implode( "\n", $titles ),
'NamespaceRestrictions' => '',
];
- $result = $page->processForm( $data, $context );
+ $result = $page->onSubmit( $data );
$this->assertTrue( $result );
@@ -419,7 +419,7 @@ class SpecialBlockTest extends SpecialPageTestBase {
// Remove a page from the partial block.
$data['PageRestrictions'] = $pageMars->getTitle()->getText();
- $result = $page->processForm( $data, $context );
+ $result = $page->onSubmit( $data );
$this->assertTrue( $result );
@@ -435,7 +435,7 @@ class SpecialBlockTest extends SpecialPageTestBase {
// Remove the last page from the block.
$data['PageRestrictions'] = '';
- $result = $page->processForm( $data, $context );
+ $result = $page->onSubmit( $data );
$this->assertTrue( $result );
@@ -448,7 +448,7 @@ class SpecialBlockTest extends SpecialPageTestBase {
// Change to sitewide.
$data['EditingRestriction'] = 'sitewide';
- $result = $page->processForm( $data, $context );
+ $result = $page->onSubmit( $data );
$this->assertTrue( $result );
@@ -469,10 +469,9 @@ class SpecialBlockTest extends SpecialPageTestBase {
/**
* @dataProvider provideProcessFormUserTalkEditFlag
- * @covers ::processForm
+ * @covers ::onSubmit
*/
public function testProcessFormUserTalkEditFlag( $options, $expected ) {
- $this->hideDeprecated( SpecialBlock::class . '::processForm' );
$this->overrideConfigValue( MainConfigNames::BlockAllowsUTEdit, $options['configAllowsUserTalkEdit'] );
$performer = $this->getTestSysop()->getUser();
@@ -500,10 +499,9 @@ class SpecialBlockTest extends SpecialPageTestBase {
$data['NamespaceRestrictions'] = '';
}
- $result = $this->newSpecialPage()->processForm(
- $data,
- $context
- );
+ $page = $this->newSpecialPage();
+ $page->setContext( $context );
+ $result = $page->onSubmit( $data );
if ( is_string( $expected ) ) {
$this->assertStatusError( $expected, $result );
@@ -577,10 +575,9 @@ class SpecialBlockTest extends SpecialPageTestBase {
/**
* @dataProvider provideProcessFormErrors
- * @covers ::processForm
+ * @covers ::onSubmit
*/
public function testProcessFormErrors( $data, $expected, $options = [] ) {
- $this->hideDeprecated( SpecialBlock::class . '::processForm' );
$this->overrideConfigValue( MainConfigNames::BlockAllowsUTEdit, true );
$performer = $this->getTestSysop()->getUser();
@@ -601,9 +598,10 @@ class SpecialBlockTest extends SpecialPageTestBase {
$context = new DerivativeContext( RequestContext::getMain() );
$context->setUser( $performer );
- $result = $this->newSpecialPage()->processForm(
- array_merge( $defaultData, $data ),
- $context
+ $page = $this->newSpecialPage();
+ $page->setContext( $context );
+ $result = $page->onSubmit(
+ array_merge( $defaultData, $data )
);
if ( $result instanceof Status ) {
@@ -686,10 +684,9 @@ class SpecialBlockTest extends SpecialPageTestBase {
/**
* @dataProvider provideProcessFormErrorsReblock
- * @covers ::processForm
+ * @covers ::onSubmit
*/
public function testProcessFormErrorsReblock( $data, $permissions, $expected ) {
- $this->hideDeprecated( SpecialBlock::class . '::processForm' );
$this->overrideConfigValue( MainConfigNames::BlockAllowsUTEdit, true );
$performer = $this->getTestSysop()->getUser();
@@ -720,9 +717,10 @@ class SpecialBlockTest extends SpecialPageTestBase {
$context = new DerivativeContext( RequestContext::getMain() );
$context->setUser( $performer );
- $result = $this->newSpecialPage()->processForm(
- array_merge( $defaultData, $data ),
- $context
+ $page = $this->newSpecialPage();
+ $page->setContext( $context );
+ $result = $page->onSubmit(
+ array_merge( $defaultData, $data )
);
if ( $result instanceof Status ) {
@@ -769,10 +767,9 @@ class SpecialBlockTest extends SpecialPageTestBase {
/**
* @dataProvider provideProcessFormErrorsHideUser
- * @covers ::processForm
+ * @covers ::onSubmit
*/
public function testProcessFormErrorsHideUser( $data, $permissions, $expected ) {
- $this->hideDeprecated( SpecialBlock::class . '::processForm' );
$performer = $this->getTestSysop()->getUser();
$this->overrideUserPermissions( $performer, array_merge( $permissions, [ 'block' ] ) );
@@ -792,9 +789,10 @@ class SpecialBlockTest extends SpecialPageTestBase {
$context = new DerivativeContext( RequestContext::getMain() );
$context->setUser( $performer );
- $result = $this->newSpecialPage()->processForm(
- array_merge( $defaultData, $data ),
- $context
+ $page = $this->newSpecialPage();
+ $page->setContext( $context );
+ $result = $page->onSubmit(
+ array_merge( $defaultData, $data )
);
if ( $result instanceof Status ) {
@@ -831,10 +829,9 @@ class SpecialBlockTest extends SpecialPageTestBase {
}
/**
- * @covers ::processForm
+ * @covers ::onSubmit
*/
public function testProcessFormErrorsHideUserProlific() {
- $this->hideDeprecated( SpecialBlock::class . '::processForm' );
$this->overrideConfigValue( MainConfigNames::HideUserContribLimit, 0 );
$performer = $this->mockRegisteredUltimateAuthority();
@@ -849,7 +846,9 @@ class SpecialBlockTest extends SpecialPageTestBase {
$context = new DerivativeContext( RequestContext::getMain() );
$context->setAuthority( $performer );
- $result = $this->newSpecialPage()->processForm(
+ $page = $this->newSpecialPage();
+ $page->setContext( $context );
+ $result = $page->onSubmit(
[
'Target' => $userToBlock,
'CreateAccount' => '1',
@@ -861,8 +860,7 @@ class SpecialBlockTest extends SpecialPageTestBase {
'HardBlock' => '0',
'AutoBlock' => '0',
'Watch' => '0',
- ],
- $context
+ ]
);
if ( $result instanceof Status ) {

File Metadata

Mime Type
text/x-diff
Expires
Sat, Jul 5, 5:32 AM (1 d, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
227715
Default Alt Text
(19 KB)

Event Timeline