Page MenuHomePhabricator
Paste P10560

(An Untitled Masterwork)
ActivePublic

Authored by Reedy on Feb 28 2020, 10:03 PM.
Tags
None
Referenced Files
F31649568: raw.txt
Feb 28 2020, 10:03 PM
Subscribers
None
24,30d23
< use MediaWiki\Block\DatabaseBlock;
< use MediaWiki\Block\Restriction\NamespaceRestriction;
< use MediaWiki\Block\Restriction\PageRestriction;
< use MediaWiki\MediaWikiServices;
< use MediaWiki\User\UserIdentity;
< use Wikimedia\IPUtils;
<
37,40c30,32
< class SpecialBlock extends FormSpecialPage {
< /** @var User|string|null User to be blocked, as passed either by parameter (url?wpTarget=Foo)
< * or as subpage (Special:Block/Foo)
< */
---
> class SpecialBlockBatch extends FormSpecialPage {
> /** @var User user to be blocked, as passed either by parameter (url?wpTarget=Foo)
> * or as subpage (Special:Block/Foo) */
43c35
< /** @var int DatabaseBlock::TYPE_ constant */
---
> /// @var Block::TYPE_ constant
46c38
< /** @var User|string The previous block target */
---
> /// @var User|String the previous block target
49c41
< /** @var bool Whether the previous submission of the form asked for HideUser */
---
> /// @var Bool whether the previous submission of the form asked for HideUser
52c44
< /** @var bool */
---
> /// @var Bool
55,56c47,48
< /** @var array */
< protected $preErrors = [];
---
> /// @var Array
> protected $preErrors = array();
59,63c51
< parent::__construct( 'Block', 'block' );
< }
<
< public function doesWrites() {
< return true;
---
> parent::__construct( 'BlockBatch', 'blockbatch' );
74c62,63
< # T17810: blocked admins should have limited access here
---
>
> # bug 15810: blocked admins should have limited access here
82,90d70
< * We allow certain special cases where user is blocked
< *
< * @return bool
< */
< public function requiresUnblock() {
< return false;
< }
<
< /**
93c73
< * @param string $par
---
> * @param $par String
107,108c87
< list( $this->previousTarget, /*...*/ ) =
< DatabaseBlock::parseTarget( $request->getVal( 'wpPreviousTarget' ) );
---
> list( $this->previousTarget, /*...*/ ) = Block::parseTarget( $request->getVal( 'wpPreviousTarget' ) );
115c94
< * @param HTMLForm $form
---
> * @param $form HTMLForm
117a97
> $form->setWrapperLegendMsg( 'blockip-legend' );
119c99
< $form->setSubmitDestructive();
---
> $form->setSubmitCallback( array( __CLASS__, 'processUIForm' ) );
121c101
< $msg = $this->alreadyBlocked ? 'ipb-change-block' : 'ipbsubmit';
---
> $msg = $this->alreadyBlocked ? 'ipb-change-block' : 'blockbatch-ipbsubmit';
124,125d103
< $this->addHelpLink( 'Help:Blocking users' );
<
128c106
< $s = $form->formatErrors( $this->preErrors );
---
> $s = HTMLForm::formatErrors( $this->preErrors );
132c110
< [ 'class' => 'error' ],
---
> array( 'class' => 'error' ),
139,142d116
< protected function getDisplayFormat() {
< return 'ooui';
< }
<
145c119
< * @return array
---
> * @return Array
148,152c122,123
< $conf = $this->getConfig();
< $enablePartialBlocks = $conf->get( 'EnablePartialBlocks' );
< $blockAllowsUTEdit = $conf->get( 'BlockAllowsUTEdit' );
<
< $this->getOutput()->enableOOUI();
---
> global $wgBlockAllowsUTEdit, $fooBar;
> $fooBar = true;
158,228c129,160
< $a = [];
<
< $a['Target'] = [
< 'type' => 'user',
< 'ipallowed' => true,
< 'iprange' => true,
< 'id' => 'mw-bi-target',
< 'size' => '45',
< 'autofocus' => true,
< 'required' => true,
< 'validation-callback' => [ __CLASS__, 'validateTargetField' ],
< 'section' => 'target',
< ];
<
< $a['Editing'] = [
< 'type' => 'check',
< 'label-message' => 'block-prevent-edit',
< 'default' => true,
< 'section' => 'actions',
< 'disabled' => $enablePartialBlocks ? false : true,
< ];
<
< if ( $enablePartialBlocks ) {
< $a['EditingRestriction'] = [
< 'type' => 'radio',
< 'cssclass' => 'mw-block-editing-restriction',
< 'options' => [
< $this->msg( 'ipb-sitewide' )->escaped() .
< new \OOUI\LabelWidget( [
< 'classes' => [ 'oo-ui-inline-help' ],
< 'label' => $this->msg( 'ipb-sitewide-help' )->text(),
< ] ) => 'sitewide',
< $this->msg( 'ipb-partial' )->escaped() .
< new \OOUI\LabelWidget( [
< 'classes' => [ 'oo-ui-inline-help' ],
< 'label' => $this->msg( 'ipb-partial-help' )->text(),
< ] ) => 'partial',
< ],
< 'section' => 'actions',
< ];
< $a['PageRestrictions'] = [
< 'type' => 'titlesmultiselect',
< 'label' => $this->msg( 'ipb-pages-label' )->text(),
< 'exists' => true,
< 'max' => 10,
< 'cssclass' => 'mw-block-restriction',
< 'showMissing' => false,
< 'excludeDynamicNamespaces' => true,
< 'input' => [
< 'autocomplete' => false
< ],
< 'section' => 'actions',
< ];
< $a['NamespaceRestrictions'] = [
< 'type' => 'namespacesmultiselect',
< 'label' => $this->msg( 'ipb-namespaces-label' )->text(),
< 'exists' => true,
< 'cssclass' => 'mw-block-restriction',
< 'input' => [
< 'autocomplete' => false
< ],
< 'section' => 'actions',
< ];
< }
<
< $a['CreateAccount'] = [
< 'type' => 'check',
< 'label-message' => 'ipbcreateaccount',
< 'default' => true,
< 'section' => 'actions',
< ];
---
> $a = array(
> 'Target' => array(
> 'type' => 'textarea',
> 'label-message' => 'ipadressorusername',
> 'tabindex' => '1',
> 'rows' => '32',
> 'id' => 'mw-bi-target',
> 'size' => '45',
> 'autofocus' => true,
> 'required' => true,
> 'validation-callback' => array( __CLASS__, 'validateTargetField' ),
> ),
> 'Expiry' => array(
> 'type' => !count( $suggestedDurations ) ? 'text' : 'selectorother',
> 'label-message' => 'ipbexpiry',
> 'required' => true,
> 'tabindex' => '2',
> 'options' => $suggestedDurations,
> 'other' => $this->msg( 'ipbother' )->text(),
> 'default' => $this->msg( 'ipb-default-expiry' )->inContentLanguage()->text(),
> ),
> 'Reason' => array(
> 'type' => 'selectandother',
> 'label-message' => 'ipbreason',
> 'options-message' => 'ipbreason-dropdown',
> ),
> 'CreateAccount' => array(
> 'type' => 'check',
> 'label-message' => 'ipbcreateaccount',
> 'default' => true,
> ),
> );
231c163
< $a['DisableEmail'] = [
---
> $a['DisableEmail'] = array(
234,235c166
< 'section' => 'actions',
< ];
---
> );
238,239c169,170
< if ( $blockAllowsUTEdit ) {
< $a['DisableUTEdit'] = [
---
> if ( $wgBlockAllowsUTEdit ) {
> $a['DisableUTEdit'] = array(
243,252c174
< 'section' => 'actions',
< ];
< }
<
< $defaultExpiry = $this->msg( 'ipb-default-expiry' )->inContentLanguage();
< if ( $this->type === DatabaseBlock::TYPE_RANGE || $this->type === DatabaseBlock::TYPE_IP ) {
< $defaultExpiryIP = $this->msg( 'ipb-default-expiry-ip' )->inContentLanguage();
< if ( !$defaultExpiryIP->isDisabled() ) {
< $defaultExpiry = $defaultExpiryIP;
< }
---
> );
255,274c177
< $a['Expiry'] = [
< 'type' => 'expiry',
< 'required' => true,
< 'options' => $suggestedDurations,
< 'default' => $defaultExpiry->text(),
< 'section' => 'expiry',
< ];
<
< $a['Reason'] = [
< 'type' => 'selectandother',
< // HTML maxlength uses "UTF-16 code units", which means that characters outside BMP
< // (e.g. emojis) count for two each. This limit is overridden in JS to instead count
< // Unicode codepoints.
< 'maxlength' => CommentStore::COMMENT_CHARACTER_LIMIT,
< 'maxlength-unit' => 'codepoints',
< 'options-message' => 'ipbreason-dropdown',
< 'section' => 'reason',
< ];
<
< $a['AutoBlock'] = [
---
> $a['AutoBlock'] = array(
278,279c181
< 'section' => 'options',
< ];
---
> );
282,286c184,185
< if ( MediaWikiServices::getInstance()
< ->getPermissionManager()
< ->userHasRight( $user, 'hideuser' )
< ) {
< $a['HideUser'] = [
---
> if ( $user->isAllowed( 'hideuser' ) ) {
> $a['HideUser'] = array(
290,291c189
< 'section' => 'options',
< ];
---
> );
296c194
< $a['Watch'] = [
---
> $a['Watch'] = array(
299,300c197
< 'section' => 'options',
< ];
---
> );
303c200
< $a['HardBlock'] = [
---
> $a['HardBlock'] = array(
307,308c204
< 'section' => 'options',
< ];
---
> );
312c208
< $a['PreviousTarget'] = [
---
> $a['PreviousTarget'] = array(
315c211
< ];
---
> );
318c214
< $a['Confirm'] = [
---
> $a['Confirm'] = array(
322,323c218
< 'cssclass' => 'mw-block-confirm',
< ];
---
> );
328c223
< Hooks::run( 'SpecialBlockModifyFormFields', [ $this, &$a ] );
---
> wfRunHooks( 'SpecialBlockModifyFormFields', array( $this, &$a ) );
336c231,233
< * @param array &$fields HTMLForm descriptor array
---
> * @param array $fields HTMLForm descriptor array
> * @return Bool whether fields were altered (that is, whether the target is
> * already blocked)
342,349d238
< if ( $this->target ) {
< $status = self::validateTarget( $this->target, $this->getUser() );
< if ( !$status->isOK() ) {
< $errors = $status->getErrorsArray();
< $this->preErrors = array_merge( $this->preErrors, $errors );
< }
< }
<
353c242
< $block = DatabaseBlock::newFromTarget( $this->target );
---
> $block = Block::newFromTarget( $this->target );
355,359c244,246
< // Populate fields if there is a block that is not an autoblock; if it is a range
< // block, only populate the fields if the range is the same as $this->target
< if ( $block instanceof DatabaseBlock && $block->getType() !== DatabaseBlock::TYPE_AUTO
< && ( $this->type != DatabaseBlock::TYPE_RANGE
< || $block->getTarget() == $this->target )
---
> if ( $block instanceof Block && !$block->mAuto # The block exists and isn't an autoblock
> && ( $this->type != Block::TYPE_RANGE # The block isn't a rangeblock
> || $block->getTarget() == $this->target ) # or if it is, the range is what we're about to block
362c249
< $fields['CreateAccount']['default'] = $block->isCreateAccountBlocked();
---
> $fields['CreateAccount']['default'] = $block->prevents( 'createaccount' );
366c253
< $fields['DisableEmail']['default'] = $block->isEmailBlocked();
---
> $fields['DisableEmail']['default'] = $block->prevents( 'sendemail' );
370c257
< $fields['HideUser']['default'] = $block->getHideName();
---
> $fields['HideUser']['default'] = $block->mHideName;
374c261
< $fields['DisableUTEdit']['default'] = !$block->isUsertalkEditAllowed();
---
> $fields['DisableUTEdit']['default'] = $block->prevents( 'editownusertalk' );
378,383c265,267
< // unless this user also has rights to hideuser: T37839
< if ( !$block->getHideName() || MediaWikiServices::getInstance()
< ->getPermissionManager()
< ->userHasRight( $this->getUser(), 'hideuser' )
< ) {
< $fields['Reason']['default'] = $block->getReasonComment()->text;
---
> // unless this user also has rights to hideuser: Bug 35839
> if ( !$block->mHideName || $this->getUser()->isAllowed( 'hideuser' ) ) {
> $fields['Reason']['default'] = $block->mReason;
399c283
< if ( $block->getExpiry() == 'infinity' ) {
---
> if ( $block->mExpiry == 'infinity' ) {
402c286
< $fields['Expiry']['default'] = wfTimestamp( TS_RFC2822, $block->getExpiry() );
---
> $fields['Expiry']['default'] = wfTimestamp( TS_RFC2822, $block->mExpiry );
406,412c290
< $this->preErrors[] = [ 'ipb-needreblock', wfEscapeWikiText( (string)$block->getTarget() ) ];
< }
<
< if ( $this->alreadyBlocked || $this->getRequest()->wasPosted()
< || $this->getRequest()->getCheck( 'wpCreateAccount' )
< ) {
< $this->getOutput()->addJsConfigVars( 'wgCreateAccountDirty', true );
---
> $this->preErrors[] = array( 'ipb-needreblock', wfEscapeWikiText( (string)$block->getTarget() ) );
419c297
< $this->preErrors[] = [ 'ipb-confirmhideuser', 'ipb-confirmaction' ];
---
> $this->preErrors[] = array( 'ipb-confirmhideuser', 'ipb-confirmaction' );
426,467c304
< $this->preErrors[] = [ 'ipb-blockingself', 'ipb-confirmaction' ];
< }
<
< if ( $this->getConfig()->get( 'EnablePartialBlocks' ) ) {
< if ( $block instanceof DatabaseBlock && !$block->isSitewide() ) {
< $fields['EditingRestriction']['default'] = 'partial';
< } else {
< $fields['EditingRestriction']['default'] = 'sitewide';
< }
<
< if ( $block instanceof DatabaseBlock ) {
< $pageRestrictions = [];
< $namespaceRestrictions = [];
< foreach ( $block->getRestrictions() as $restriction ) {
< switch ( $restriction->getType() ) {
< case PageRestriction::TYPE:
< /** @var PageRestriction $restriction */
< '@phan-var PageRestriction $restriction';
< if ( $restriction->getTitle() ) {
< $pageRestrictions[] = $restriction->getTitle()->getPrefixedText();
< }
< break;
< case NamespaceRestriction::TYPE:
< $namespaceRestrictions[] = $restriction->getValue();
< break;
< }
< }
<
< if (
< !$block->isSitewide() &&
< empty( $pageRestrictions ) &&
< empty( $namespaceRestrictions )
< ) {
< $fields['Editing']['default'] = false;
< }
<
< // Sort the restrictions so they are in alphabetical order.
< sort( $pageRestrictions );
< $fields['PageRestrictions']['default'] = implode( "\n", $pageRestrictions );
< sort( $namespaceRestrictions );
< $fields['NamespaceRestrictions']['default'] = implode( "\n", $namespaceRestrictions );
< }
---
> $this->preErrors[] = array( 'ipb-blockingself', 'ipb-confirmaction' );
473c310
< * @return string
---
> * @return String
476,480c313
< $this->getOutput()->addModuleStyles( [
< 'mediawiki.widgets.TagMultiselectWidget.styles',
< 'mediawiki.special',
< ] );
< $this->getOutput()->addModules( [ 'mediawiki.special.block' ] );
---
> $this->getOutput()->addModules( 'mediawiki.special.block' );
482,483c315
< $blockCIDRLimit = $this->getConfig()->get( 'BlockCIDRLimit' );
< $text = $this->msg( 'blockiptext', $blockCIDRLimit['IPv4'], $blockCIDRLimit['IPv6'] )->parse();
---
> $text = $this->msg( 'blockbatch-iptext' )->parse();
485c317
< $otherBlockMessages = [];
---
> $otherBlockMessages = array();
487,490d318
< $targetName = $this->target;
< if ( $this->target instanceof User ) {
< $targetName = $this->target->getName();
< }
492c320
< Hooks::run( 'OtherBlockLogLink', [ &$otherBlockMessages, $targetName ] );
---
> wfRunHooks( 'OtherBlockLogLink', array( &$otherBlockMessages, $this->target ) );
497c325
< [],
---
> array(),
503d330
< // @phan-suppress-next-line PhanEmptyForeach False positive
505c332
< $list .= Html::rawElement( 'li', [], $link ) . "\n";
---
> $list .= Html::rawElement( 'li', array(), $link ) . "\n";
510c337
< [ 'class' => 'mw-blockip-alreadyblocked' ],
---
> array( 'class' => 'mw-blockip-alreadyblocked' ),
526,528c353
< $links = [];
<
< $this->getOutput()->addModuleStyles( 'mediawiki.special' );
---
> $links = array();
530d354
< $linkRenderer = $this->getLinkRenderer();
534c358
< $links[] = $linkRenderer->makeLink(
---
> $links[] = Linker::link(
536c360
< $this->msg( 'ipb-blocklist-contribs', $this->target->getName() )->text()
---
> $this->msg( 'ipb-blocklist-contribs', $this->target->getName() )->escaped()
542,545c366
< $message = $this->msg(
< 'ipb-unblock-addr',
< wfEscapeWikiText( $this->target->getName() )
< )->parse();
---
> $message = $this->msg( 'ipb-unblock-addr', wfEscapeWikiText( $this->target->getName() ) )->parse();
551,554c372
< $links[] = $linkRenderer->makeKnownLink(
< $list,
< new HtmlArmor( $message )
< );
---
> $links[] = Linker::linkKnown( $list, $message, array() );
557c375
< $links[] = $linkRenderer->makeKnownLink(
---
> $links[] = Linker::linkKnown(
559c377
< $this->msg( 'ipb-blocklist' )->text()
---
> $this->msg( 'ipb-blocklist' )->escaped()
565,571c383,388
< $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
< if ( $permissionManager->userHasRight( $user, 'editinterface' ) ) {
< $links[] = $linkRenderer->makeKnownLink(
< $this->msg( 'ipbreason-dropdown' )->inContentLanguage()->getTitle(),
< $this->msg( 'ipb-edit-dropdown' )->text(),
< [],
< [ 'action' => 'edit' ]
---
> if ( $user->isAllowed( 'editinterface' ) ) {
> $links[] = Linker::link(
> Title::makeTitle( NS_MEDIAWIKI, 'Ipbreason-dropdown' ),
> $this->msg( 'ipb-edit-dropdown' )->escaped(),
> array(),
> array( 'action' => 'edit' )
577c394
< [ 'class' => 'mw-ipb-conveniencelinks' ],
---
> array( 'class' => 'mw-ipb-conveniencelinks' ),
591c408
< [
---
> array(
593c410
< 'msgKey' => [ 'blocklog-showlog', $userTitle->getText() ],
---
> 'msgKey' => array( 'blocklog-showlog', $userTitle->getText() ),
595c412
< ]
---
> )
600c417
< if ( $permissionManager->userHasRight( $user, 'suppressionlog' ) ) {
---
> if ( $user->isAllowed( 'suppressionlog' ) ) {
606c423
< [
---
> array(
608,609c425,426
< 'conds' => [ 'log_action' => [ 'block', 'reblock', 'unblock' ] ],
< 'msgKey' => [ 'blocklog-showsuppresslog', $userTitle->getText() ],
---
> 'conds' => array( 'log_action' => array( 'block', 'reblock', 'unblock' ) ),
> 'msgKey' => array( 'blocklog-showsuppresslog', $userTitle->getText() ),
611c428
< ]
---
> )
624c441
< * @param User|string $target
---
> * @param $target User|string
630c447
< } elseif ( IPUtils::isIPAddress( $target ) ) {
---
> } elseif ( IP::isIPAddress( $target ) ) {
639,640c456,457
< * @todo Should be in DatabaseBlock.php?
< * @param string $par Subpage parameter passed to setup, or data value from
---
> * TODO: should be in Block.php?
> * @param string $par subpage parameter passed to setup, or data value from
642,644c459,460
< * @param WebRequest|null $request Optionally try and get data from a request too
< * @return array [ User|string|null, DatabaseBlock::TYPE_ constant|null ]
< * @phan-return array{0:User|string|null,1:int|null}
---
> * @param $request WebRequest optionally try and get data from a request too
> * @return array( User|string|null, Block::TYPE_ constant|null )
679c495
< list( $target, $type ) = DatabaseBlock::parseTarget( $target );
---
> list( $target, $type ) = Block::parseTarget( $target );
682c498
< return [ $target, $type ];
---
> return array( $target, $type );
686c502
< return [ null, null ];
---
> return array( null, null );
692,694c508,510
< * @param string $value
< * @param array $alldata
< * @param HTMLForm $form
---
> * @param $value String
> * @param $alldata Array
> * @param $form HTMLForm
698,700c514,517
< $status = self::validateTarget( $value, $form->getUser() );
< if ( !$status->isOK() ) {
< $errors = $status->getErrorsArray();
---
> foreach ( explode( "\n", $value ) as $thisValue ) {
> $status = self::validateTarget( $thisValue, $form->getUser() );
> if ( !$status->isOK() ) {
> $errors = $status->getErrorsArray();
702,704c519,520
< return $form->msg( ...$errors[0] );
< } else {
< return true;
---
> return call_user_func_array( array( $form, 'msg' ), $errors[0] );
> }
705a522
> return true;
723c540
< if ( $type == DatabaseBlock::TYPE_USER ) {
---
> if ( $type == Block::TYPE_USER ) {
735c552
< } elseif ( $type == DatabaseBlock::TYPE_RANGE ) {
---
> } elseif ( $type == Block::TYPE_RANGE ) {
739,740c556,557
< ( IPUtils::isIPv4( $ip ) && $wgBlockCIDRLimit['IPv4'] == 32 ) ||
< ( IPUtils::isIPv6( $ip ) && $wgBlockCIDRLimit['IPv6'] == 128 )
---
> ( IP::isIPv4( $ip ) && $wgBlockCIDRLimit['IPv4'] == 32 ) ||
> ( IP::isIPv6( $ip ) && $wgBlockCIDRLimit['IPv6'] == 128 )
747,748c564,565
< ( IPUtils::isIPv4( $ip ) && $range > 32 ) ||
< ( IPUtils::isIPv6( $ip ) && $range > 128 )
---
> ( IP::isIPv4( $ip ) && $range > 32 ) ||
> ( IP::isIPv6( $ip ) && $range > 128 )
754c571
< if ( IPUtils::isIPv4( $ip ) && $range < $wgBlockCIDRLimit['IPv4'] ) {
---
> if ( IP::isIPv4( $ip ) && $range < $wgBlockCIDRLimit['IPv4'] ) {
758c575
< if ( IPUtils::isIPv6( $ip ) && $range < $wgBlockCIDRLimit['IPv6'] ) {
---
> if ( IP::isIPv6( $ip ) && $range < $wgBlockCIDRLimit['IPv6'] ) {
761c578
< } elseif ( $type == DatabaseBlock::TYPE_IP ) {
---
> } elseif ( $type == Block::TYPE_IP ) {
771,775c588,601
< * Given the form data, actually implement a block. This is also called from ApiBlock.
< *
< * @param array $data
< * @param IContextSource $context
< * @return bool|array
---
> * Submit callback for an HTMLForm object, will simply pass
> * @param $data array
> * @param $form HTMLForm
> * @return Bool|String
> */
> public static function processUIForm( array $data, HTMLForm $form ) {
> return self::processForm( $data, $form->getContext() );
> }
>
> /**
> * Given the form data, actually implement a block
> * @param $data Array
> * @param $context IContextSource
> * @return Bool|String
777a604,606
> global $wgBlockAllowsUTEdit, $wgHideUserContribLimit;
> global $targetList;
>
779,782c608,610
< $enablePartialBlocks = $context->getConfig()->get( 'EnablePartialBlocks' );
< $isPartialBlock = $enablePartialBlocks &&
< isset( $data['EditingRestriction'] ) &&
< $data['EditingRestriction'] === 'partial';
---
>
> // Handled by field validator callback
> // self::validateTargetField( $data['Target'] );
786c614
< $data['Confirm'] = !in_array( $data['Confirm'], [ '', '0', null, false ], true );
---
> $data['Confirm'] = !in_array( $data['Confirm'], array( '', '0', null, false ), true );
788,805c616,643
< /** @var User $target */
< list( $target, $type ) = self::getTargetAndType( $data['Target'] );
< if ( $type == DatabaseBlock::TYPE_USER ) {
< $user = $target;
< $target = $user->getName();
< $userId = $user->getId();
<
< # 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'
< # permission anyway, although the code does allow for it.
< # Note: Important to use $target instead of $data['Target']
< # since both $data['PreviousTarget'] and $target are normalized
< # but $data['target'] gets overridden by (non-normalized) request variable
< # from previous request.
< if ( $target === $performer->getName() &&
< ( $data['PreviousTarget'] !== $target || !$data['Confirm'] )
< ) {
< return [ 'ipb-blockingself', 'ipb-confirmaction' ];
---
> foreach( explode( "\n", $data['Target'] ) as $thisTarget ) {
> /** @var User $target */
> list( $target, $type ) = self::getTargetAndType( $thisTarget );
> if ( $type == Block::TYPE_USER ) {
> $user = $target;
> $target = $user->getName();
> $userId = $user->getId();
>
> # 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'
> # permission anyway, although the code does allow for it.
> # Note: Important to use $target instead of $data['Target']
> # since both $data['PreviousTarget'] and $target are normalized
> # but $data['target'] gets overriden by (non-normalized) request variable
> # from previous request.
> if ( $target === $performer->getName() &&
> ( $data['PreviousTarget'] !== $target || !$data['Confirm'] )
> ) {
> return array( 'ipb-blockingself', 'ipb-confirmaction' );
> }
> } elseif ( $type == Block::TYPE_RANGE ) {
> $userId = 0;
> } elseif ( $type == Block::TYPE_IP ) {
> $target = $target->getName();
> $userId = 0;
> } else {
> # This should have been caught in the form field validation
> return array( 'badipaddress' );
807,846d644
< } elseif ( $type == DatabaseBlock::TYPE_RANGE ) {
< $user = null;
< $userId = 0;
< } elseif ( $type == DatabaseBlock::TYPE_IP ) {
< $user = null;
< $target = $target->getName();
< $userId = 0;
< } else {
< # This should have been caught in the form field validation
< return [ 'badipaddress' ];
< }
<
< $expiryTime = self::parseExpiryInput( $data['Expiry'] );
<
< if (
< // an expiry time is needed
< ( strlen( $data['Expiry'] ) == 0 ) ||
< // can't be a larger string as 50 (it should be a time format in any way)
< ( strlen( $data['Expiry'] ) > 50 ) ||
< // check, if the time could be parsed
< !$expiryTime
< ) {
< return [ 'ipb_expiry_invalid' ];
< }
<
< // an expiry time should be in the future, not in the
< // past (wouldn't make any sense) - bug T123069
< if ( $expiryTime < wfTimestampNow() ) {
< return [ 'ipb_expiry_old' ];
< }
<
< if ( !isset( $data['DisableEmail'] ) ) {
< $data['DisableEmail'] = false;
< }
<
< # If the user has done the form 'properly', they won't even have been given the
< # option to suppress-block unless they have the 'hideuser' permission
< if ( !isset( $data['HideUser'] ) ) {
< $data['HideUser'] = false;
< }
848,872c646,647
< if ( $data['HideUser'] ) {
< if ( !MediaWikiServices::getInstance()
< ->getPermissionManager()
< ->userHasRight( $performer, 'hideuser' )
< ) {
< # this codepath is unreachable except by a malicious user spoofing forms,
< # or by race conditions (user has hideuser and block rights, loads block form,
< # and loses hideuser rights before submission); so need to fail completely
< # rather than just silently disable hiding
< return [ 'badaccess-group0' ];
< }
<
< if ( $isPartialBlock ) {
< return [ 'ipb_hide_partial' ];
< }
<
< # Recheck params here...
< $hideUserContribLimit = $context->getConfig()->get( 'HideUserContribLimit' );
< if ( $type != DatabaseBlock::TYPE_USER ) {
< $data['HideUser'] = false; # IP users should not be hidden
< } elseif ( !wfIsInfinity( $data['Expiry'] ) ) {
< # Bad expiry.
< return [ 'ipb_expiry_temp' ];
< } elseif ( $hideUserContribLimit !== false
< && $user->getEditCount() > $hideUserContribLimit
---
> if ( ( strlen( $data['Expiry'] ) == 0 ) || ( strlen( $data['Expiry'] ) > 50 )
> || !self::parseExpiryInput( $data['Expiry'] )
874,879c649
< # Typically, the user should have a handful of edits.
< # Disallow hiding users with many edits for performance.
< return [ [ 'ipb_hide_invalid',
< Message::numParam( $hideUserContribLimit ) ] ];
< } elseif ( !$data['Confirm'] ) {
< return [ 'ipb-confirmhideuser', 'ipb-confirmaction' ];
---
> return array( 'ipb_expiry_invalid' );
881d650
< }
883,993c652,654
< $blockAllowsUTEdit = $context->getConfig()->get( 'BlockAllowsUTEdit' );
< $userTalkEditAllowed = !$blockAllowsUTEdit || !$data['DisableUTEdit'];
< if ( !$userTalkEditAllowed &&
< $isPartialBlock &&
< !in_array( NS_USER_TALK, explode( "\n", $data['NamespaceRestrictions'] ) )
< ) {
< return [ 'ipb-prevent-user-talk-edit' ];
< }
<
< # Create block object.
< $block = new DatabaseBlock();
< $block->setTarget( $target );
< $block->setBlocker( $performer );
< $block->setReason( $data['Reason'][0] );
< $block->setExpiry( $expiryTime );
< $block->isCreateAccountBlocked( $data['CreateAccount'] );
< $block->isUsertalkEditAllowed( $userTalkEditAllowed );
< $block->isEmailBlocked( $data['DisableEmail'] );
< $block->isHardblock( $data['HardBlock'] );
< $block->isAutoblocking( $data['AutoBlock'] );
< $block->setHideName( $data['HideUser'] );
<
< if ( $isPartialBlock ) {
< $block->isSitewide( false );
< }
<
< $reason = [ 'hookaborted' ];
< if ( !Hooks::run( 'BlockIp', [ &$block, &$performer, &$reason ] ) ) {
< return $reason;
< }
<
< $pageRestrictions = [];
< $namespaceRestrictions = [];
< if ( $enablePartialBlocks ) {
< if ( $data['PageRestrictions'] !== '' ) {
< $pageRestrictions = array_map( function ( $text ) {
< $title = Title::newFromText( $text );
< // Use the link cache since the title has already been loaded when
< // the field was validated.
< $restriction = new PageRestriction( 0, $title->getArticleID() );
< $restriction->setTitle( $title );
< return $restriction;
< }, explode( "\n", $data['PageRestrictions'] ) );
< }
< if ( $data['NamespaceRestrictions'] !== '' ) {
< $namespaceRestrictions = array_map( function ( $id ) {
< return new NamespaceRestriction( 0, $id );
< }, explode( "\n", $data['NamespaceRestrictions'] ) );
< }
<
< $restrictions = ( array_merge( $pageRestrictions, $namespaceRestrictions ) );
< $block->setRestrictions( $restrictions );
< }
<
< $priorBlock = null;
< # Try to insert block. Is there a conflicting block?
< $status = $block->insert();
< if ( !$status ) {
< # Indicates whether the user is confirming the block and is aware of
< # the conflict (did not change the block target in the meantime)
< $blockNotConfirmed = !$data['Confirm'] || ( array_key_exists( 'PreviousTarget', $data )
< && $data['PreviousTarget'] !== $target );
<
< # Special case for API - T34434
< $reblockNotAllowed = ( array_key_exists( 'Reblock', $data ) && !$data['Reblock'] );
<
< # Show form unless the user is already aware of this...
< if ( $blockNotConfirmed || $reblockNotAllowed ) {
< return [ [ 'ipb_already_blocked', $block->getTarget() ] ];
< # Otherwise, try to update the block...
< } else {
< # This returns direct blocks before autoblocks/rangeblocks, since we should
< # be sure the user is blocked by now it should work for our purposes
< $currentBlock = DatabaseBlock::newFromTarget( $target );
< if ( $block->equals( $currentBlock ) ) {
< return [ [ 'ipb_already_blocked', $block->getTarget() ] ];
< }
< # If the name was hidden and the blocking user cannot hide
< # names, then don't allow any block changes...
< if ( $currentBlock->getHideName() && !MediaWikiServices::getInstance()
< ->getPermissionManager()
< ->userHasRight( $performer, 'hideuser' )
< ) {
< return [ 'cant-see-hidden-user' ];
< }
<
< $priorBlock = clone $currentBlock;
< $currentBlock->setBlocker( $performer );
< $currentBlock->isHardblock( $block->isHardblock() );
< $currentBlock->isCreateAccountBlocked( $block->isCreateAccountBlocked() );
< $currentBlock->setExpiry( $block->getExpiry() );
< $currentBlock->isAutoblocking( $block->isAutoblocking() );
< $currentBlock->setHideName( $block->getHideName() );
< $currentBlock->isEmailBlocked( $block->isEmailBlocked() );
< $currentBlock->isUsertalkEditAllowed( $block->isUsertalkEditAllowed() );
< $currentBlock->setReason( $block->getReasonComment() );
<
< if ( $enablePartialBlocks ) {
< // Maintain the sitewide status. If partial blocks is not enabled,
< // saving the block will result in a sitewide block.
< $currentBlock->isSitewide( $block->isSitewide() );
<
< // Set the block id of the restrictions.
< $blockRestrictionStore = MediaWikiServices::getInstance()->getBlockRestrictionStore();
< $currentBlock->setRestrictions(
< $blockRestrictionStore->setBlockId( $currentBlock->getId(), $restrictions )
< );
< }
<
< $status = $currentBlock->update();
< // TODO handle failure
---
> if ( !isset( $data['DisableEmail'] ) ) {
> $data['DisableEmail'] = false;
> }
995c656,660
< $logaction = 'reblock';
---
> # If the user has done the form 'properly', they won't even have been given the
> # option to suppress-block unless they have the 'hideuser' permission
> if ( !isset( $data['HideUser'] ) ) {
> $data['HideUser'] = false;
> }
997,999c662,668
< # Unset _deleted fields if requested
< if ( $currentBlock->getHideName() && !$data['HideUser'] ) {
< RevisionDeleteUser::unsuppressUserName( $target, $userId );
---
> if ( $data['HideUser'] ) {
> if ( !$performer->isAllowed( 'hideuser' ) ) {
> # this codepath is unreachable except by a malicious user spoofing forms,
> # or by race conditions (user has oversight and sysop, loads block form,
> # and is de-oversighted before submission); so need to fail completely
> # rather than just silently disable hiding
> return array( 'badaccess-group0' );
1002,1004c671,685
< # If hiding/unhiding a name, this should go in the private logs
< if ( (bool)$currentBlock->getHideName() ) {
< $data['HideUser'] = true;
---
> # Recheck params here...
> if ( $type != Block::TYPE_USER ) {
> $data['HideUser'] = false; # IP users should not be hidden
> } elseif ( !in_array( $data['Expiry'], array( 'infinite', 'infinity', 'indefinite' ) ) ) {
> # Bad expiry.
> return array( 'ipb_expiry_temp' );
> } elseif ( $wgHideUserContribLimit !== false
> && $user->getEditCount() > $wgHideUserContribLimit
> ) {
> # Typically, the user should have a handful of edits.
> # Disallow hiding users with many edits for performance.
> return array( array( 'ipb_hide_invalid',
> Message::numParam( $wgHideUserContribLimit ) ) );
> } elseif ( !$data['Confirm'] ) {
> return array( 'ipb-confirmhideuser', 'ipb-confirmaction' );
1006,1007d686
<
< $block = $currentBlock;
1009,1013d687
< } else {
< $logaction = 'block';
< }
<
< Hooks::run( 'BlockIpComplete', [ $block, $performer, $priorBlock ] );
1015,1018c689,725
< # Set *_deleted fields if requested
< if ( $data['HideUser'] ) {
< RevisionDeleteUser::suppressUserName( $target, $userId );
< }
---
> # Create block object.
> $block = new Block();
> $block->setTarget( $target );
> $block->setBlocker( $performer );
> $block->mReason = $data['Reason'][0];
> $block->mExpiry = self::parseExpiryInput( $data['Expiry'] );
> $block->prevents( 'createaccount', $data['CreateAccount'] );
> $block->prevents( 'editownusertalk', ( !$wgBlockAllowsUTEdit || $data['DisableUTEdit'] ) );
> $block->prevents( 'sendemail', $data['DisableEmail'] );
> $block->isHardblock( $data['HardBlock'] );
> $block->isAutoblocking( $data['AutoBlock'] );
> $block->mHideName = $data['HideUser'];
>
> $reason = array( 'hookaborted' );
> if ( !wfRunHooks( 'BlockIp', array( &$block, &$performer, &$reason ) ) ) {
> return $reason;
> }
>
> # Try to insert block. Is there a conflicting block?
> $status = $block->insert();
> if ( !$status ) {
> # Indicates whether the user is confirming the block and is aware of
> # the conflict (did not change the block target in the meantime)
> $blockNotConfirmed = !$data['Confirm'] || ( array_key_exists( 'PreviousTarget', $data )
> && $data['PreviousTarget'] !== $target );
>
> # Special case for API - bug 32434
> $reblockNotAllowed = ( array_key_exists( 'Reblock', $data ) && !$data['Reblock'] );
>
> # Show form unless the user is already aware of this...
> if ( $blockNotConfirmed || $reblockNotAllowed ) {
> return array( array( 'ipb_already_blocked', $block->getTarget() ) );
> # Otherwise, try to update the block...
> } else {
> # This returns direct blocks before autoblocks/rangeblocks, since we should
> # be sure the user is blocked by now it should work for our purposes
> $currentBlock = Block::newFromTarget( $target );
1020,1027c727,729
< # Can't watch a rangeblock
< if ( $type != DatabaseBlock::TYPE_RANGE && $data['Watch'] ) {
< WatchAction::doWatch(
< Title::makeTitle( NS_USER, $target ),
< $performer,
< User::IGNORE_USER_RIGHTS
< );
< }
---
> if ( $block->equals( $currentBlock ) ) {
> return array( array( 'ipb_already_blocked', $block->getTarget() ) );
> }
1029,1031c731,735
< # DatabaseBlock constructor sanitizes certain block options on insert
< $data['BlockEmail'] = $block->isEmailBlocked();
< $data['AutoBlock'] = $block->isAutoblocking();
---
> # If the name was hidden and the blocking user cannot hide
> # names, then don't allow any block changes...
> if ( $currentBlock->mHideName && !$performer->isAllowed( 'hideuser' ) ) {
> return array( 'cant-see-hidden-user' );
> }
1033,1034c737,744
< # Prepare log parameters
< $logParams = [];
---
> $currentBlock->delete();
> $status = $block->insert();
> $logaction = 'reblock';
>
> # Unset _deleted fields if requested
> if ( $currentBlock->mHideName && !$data['HideUser'] ) {
> RevisionDeleteUser::unsuppressUserName( $target, $userId );
> }
1036,1037c746,753
< $rawExpiry = $data['Expiry'];
< $logExpiry = wfIsInfinity( $rawExpiry ) ? 'infinity' : $rawExpiry;
---
> # If hiding/unhiding a name, this should go in the private logs
> if ( (bool)$currentBlock->mHideName ) {
> $data['HideUser'] = true;
> }
> }
> } else {
> $logaction = 'block';
> }
1039,1041c755
< $logParams['5::duration'] = $logExpiry;
< $logParams['6::flags'] = self::blockLogFlags( $data, $type );
< $logParams['sitewide'] = $block->isSitewide();
---
> wfRunHooks( 'BlockIpComplete', array( $block, $performer ) );
1043,1045c757,759
< if ( $enablePartialBlocks && !$block->isSitewide() ) {
< if ( $data['PageRestrictions'] !== '' ) {
< $logParams['7::restrictions']['pages'] = explode( "\n", $data['PageRestrictions'] );
---
> # Set *_deleted fields if requested
> if ( $data['HideUser'] ) {
> RevisionDeleteUser::suppressUserName( $target, $userId );
1048,1049c762,764
< if ( $data['NamespaceRestrictions'] !== '' ) {
< $logParams['7::restrictions']['namespaces'] = explode( "\n", $data['NamespaceRestrictions'] );
---
> # Can't watch a rangeblock
> if ( $type != Block::TYPE_RANGE && $data['Watch'] ) {
> WatchAction::doWatch( Title::makeTitle( NS_USER, $target ), $performer, WatchedItem::IGNORE_USER_RIGHTS );
1051d765
< }
1053,1062c767,769
< # Make log entry, if the name is hidden, put it in the suppression log
< $log_type = $data['HideUser'] ? 'suppress' : 'block';
< $logEntry = new ManualLogEntry( $log_type, $logaction );
< $logEntry->setTarget( Title::makeTitle( NS_USER, $target ) );
< $logEntry->setComment( $data['Reason'][0] );
< $logEntry->setPerformer( $performer );
< $logEntry->setParameters( $logParams );
< # Relate log ID to block ID (T27763)
< $logEntry->setRelations( [ 'ipb_id' => $block->getId() ] );
< $logId = $logEntry->insert();
---
> # Block constructor sanitizes certain block options on insert
> $data['BlockEmail'] = $block->prevents( 'sendemail' );
> $data['AutoBlock'] = $block->isAutoblocking();
1064,1066c771,774
< if ( !empty( $data['Tags'] ) ) {
< $logEntry->addTags( $data['Tags'] );
< }
---
> # Prepare log parameters
> $logParams = array();
> $logParams[] = $data['Expiry'];
> $logParams[] = self::blockLogFlags( $data, $type );
1068c776,788
< $logEntry->publish( $logId );
---
> # Make log entry, if the name is hidden, put it in the oversight log
> $log_type = $data['HideUser'] ? 'suppress' : 'block';
> $log = new LogPage( $log_type );
> $log_id = $log->addEntry(
> $logaction,
> Title::makeTitle( NS_USER, $target ),
> $data['Reason'][0],
> $logParams,
> $performer
> );
> # Relate log ID to block IDs (bug 25763)
> $blockIds = array_merge( array( $status['id'] ), $status['autoIds'] );
> $log->addRelations( 'ipb_id', $blockIds, $log_id );
1069a790,793
> $targetList[] = $user->getName();
>
> # Report to the user
> }
1077c801
< * @param Language|null $lang The language to get the durations in, or null to use
---
> * @param $lang Language|null the language to get the durations in, or null to use
1079,1081c803
< * @param bool $includeOther Whether to include the 'other' option in the list of
< * suggestions
< * @return array
---
> * @return Array
1083,1084c805,806
< public static function getSuggestedDurations( Language $lang = null, $includeOther = true ) {
< $a = [];
---
> public static function getSuggestedDurations( $lang = null ) {
> $a = array();
1090c812
< return [];
---
> return array();
1099,1105c821
< $a[$show] = $value;
< }
<
< if ( $a && $includeOther ) {
< // if options exist, add other to the end instead of the begining (which
< // is what happens by default).
< $a[ wfMessage( 'ipbother' )->text() ] = 'other';
---
> $a[htmlspecialchars( $show )] = htmlspecialchars( $value );
1114,1120c830,831
< *
< * @todo strtotime() only accepts English strings. This means the expiry input
< * can only be specified in English.
< * @see https://www.php.net/manual/en/function.strtotime.php
< *
< * @param string $expiry Whatever was typed into the form
< * @return string|bool Timestamp or 'infinity' or false on error.
---
> * @param string $expiry whatever was typed into the form
> * @return String: timestamp or "infinity" string for the DB implementation
1123,1124c834,836
< if ( wfIsInfinity( $expiry ) ) {
< return 'infinity';
---
> static $infinity;
> if ( $infinity == null ) {
> $infinity = wfGetDB( DB_SLAVE )->getInfinity();
1127c839,842
< $expiry = strtotime( $expiry );
---
> if ( $expiry == 'infinite' || $expiry == 'indefinite' ) {
> $expiry = $infinity;
> } else {
> $expiry = strtotime( $expiry );
1129,1130c844,848
< if ( $expiry < 0 || $expiry === false ) {
< return false;
---
> if ( $expiry < 0 || $expiry === false ) {
> return false;
> }
>
> $expiry = wfTimestamp( TS_MW, $expiry );
1133c851
< return wfTimestamp( TS_MW, $expiry );
---
> return $expiry;
1138,1139c856,857
< * @param UserIdentity $user The sysop wanting to make a block
< * @return bool
---
> * @param $user User: the sysop wanting to make a block
> * @return Boolean
1141,1142c859,860
< public static function canBlockEmail( UserIdentity $user ) {
< global $wgEnableUserEmail;
---
> public static function canBlockEmail( $user ) {
> global $wgEnableUserEmail, $wgSysopEmailBans;
1144,1146c862
< return ( $wgEnableUserEmail && MediaWikiServices::getInstance()
< ->getPermissionManager()
< ->userHasRight( $user, 'blockemail' ) );
---
> return ( $wgEnableUserEmail && $wgSysopEmailBans && $user->isAllowed( 'blockemail' ) );
1150c866
< * T17810: blocked admins should not be able to block/unblock
---
> * bug 15810: blocked admins should not be able to block/unblock
1153,1167c869,877
< *
< * Exception: Users can block the user who blocked them, to reduce
< * advantage of a malicious account blocking all admins (T150826)
< *
< * @param User|int|string|null $target Target to block or unblock; could be a User object,
< * or a user ID or username, or null when the target is not known yet (e.g. when
< * displaying Special:Block)
< * @param User $performer User doing the request
< * @return bool|string True or error message key
< */
< public static function checkUnblockSelf( $target, User $performer ) {
< if ( is_int( $target ) ) {
< $target = User::newFromId( $target );
< } elseif ( is_string( $target ) ) {
< $target = User::newFromName( $target );
---
> * @param $user User|Int|String
> * @param $performer User user doing the request
> * @return Bool|String true or error message key
> */
> public static function checkUnblockSelf( $user, User $performer ) {
> if ( is_int( $user ) ) {
> $user = User::newFromId( $user );
> } elseif ( is_string( $user ) ) {
> $user = User::newFromName( $user );
1169,1170c879,881
< if ( $performer->getBlock() ) {
< if ( $target instanceof User && $target->getId() == $performer->getId() ) {
---
>
> if ( $performer->isBlocked() ) {
> if ( $user instanceof User && $user->getId() == $performer->getId() ) {
1172,1175c883
< if ( MediaWikiServices::getInstance()
< ->getPermissionManager()
< ->userHasRight( $performer, 'unblockself' )
< ) {
---
> if ( $performer->isAllowed( 'unblockself' ) ) {
1183,1195d890
< } elseif (
< $target instanceof User &&
< $performer->getBlock() instanceof DatabaseBlock &&
< $performer->getBlock()->getBy() &&
< $performer->getBlock()->getBy() === $target->getId()
< ) {
< // Allow users to block the user that blocked them.
< // This is to prevent a situation where a malicious user
< // blocks all other users. This way, the non-malicious
< // user can block the malicious user back, resulting
< // in a stalemate.
< return true;
<
1208,1209c903,904
< * @param array $data From HTMLForm data
< * @param int $type DatabaseBlock::TYPE_ constant (USER, RANGE, or IP)
---
> * @param array $data from HTMLForm data
> * @param $type Block::TYPE_ constant (USER, RANGE, or IP)
1213,1217c908,909
< $config = RequestContext::getMain()->getConfig();
<
< $blockAllowsUTEdit = $config->get( 'BlockAllowsUTEdit' );
<
< $flags = [];
---
> global $wgBlockAllowsUTEdit;
> $flags = array();
1221c913
< if ( !$data['HardBlock'] && $type != DatabaseBlock::TYPE_USER ) {
---
> if ( !$data['HardBlock'] && $type != Block::TYPE_USER ) {
1232c924
< if ( !$data['AutoBlock'] && $type == DatabaseBlock::TYPE_USER ) {
---
> if ( !$data['AutoBlock'] && $type == Block::TYPE_USER ) {
1242c934
< if ( $blockAllowsUTEdit && $data['DisableUTEdit'] ) {
---
> if ( $wgBlockAllowsUTEdit && $data['DisableUTEdit'] ) {
1257,1259c949,950
< * @param array $data
< * @param HTMLForm|null $form
< * @return bool|array True for success, false for didn't-try, array of errors on failure
---
> * @param $data Array
> * @return Bool|Array true for success, false for didn't-try, array of errors on failure
1261,1269c952,954
< public function onSubmit( array $data, HTMLForm $form = null ) {
< // If "Editing" checkbox is unchecked, the block must be a partial block affecting
< // actions other than editing, and there must be no restrictions.
< if ( isset( $data['Editing'] ) && $data['Editing'] === false ) {
< $data['EditingRestriction'] = 'partial';
< $data['PageRestrictions'] = '';
< $data['NamespaceRestrictions'] = '';
< }
< return self::processForm( $data, $form->getContext() );
---
> public function onSubmit( array $data ) {
> // This isn't used since we need that HTMLForm that's passed in the
> // second parameter. See alterForm for the real function
1279,1294c964,966
< $out->addWikiMsg( 'blockipsuccesstext', wfEscapeWikiText( $this->target ) );
< }
<
< /**
< * Return an array of subpages beginning with $search that this special page will accept.
< *
< * @param string $search Prefix to search for
< * @param int $limit Maximum number of results to return (usually 10)
< * @param int $offset Number of results to skip (usually 0)
< * @return string[] Matching subpages
< */
< public function prefixSearchSubpages( $search, $limit, $offset ) {
< $user = User::newFromName( $search );
< if ( !$user ) {
< // No prefix suggestion for invalid user
< return [];
---
> global $targetList;
> foreach ( $targetList as $thisTarget ) {
> $out->addWikiMsg( 'blockipsuccesstext', wfEscapeWikiText( $thisTarget ) );
1296,1297d967
< // Autocomplete subpage as user list - public to allow caching
< return UserNamePrefixSearch::search( 'public', $search, $limit, $offset );
1303a974,977
>
> # BC @since 1.18
> #class IPBlockForm extends SpecialBlock {
> #}
\ No newline at end of file