MediaWiki  master
BlockUser.php
Go to the documentation of this file.
1 <?php
2 
22 namespace MediaWiki\Block;
23 
24 use ChangeTags;
26 use ManualLogEntry;
38 use Message;
39 use Psr\Log\LoggerInterface;
41 use Status;
42 use Title;
43 use TitleFactory;
44 use Wikimedia\Timestamp\ConvertibleTimestamp;
45 
51 class BlockUser {
60  private $target;
61 
69  private $targetType;
70 
72  private $performer;
73 
75  private $options;
76 
79 
82 
84  private $blockUtils;
85 
87  private $hookRunner;
88 
91 
93  private $userFactory;
94 
97 
99  private $logger;
100 
102  private $titleFactory;
103 
106 
110  public const CONSTRUCTOR_OPTIONS = [
111  'HideUserContribLimit',
112  'BlockAllowsUTEdit',
113  ];
114 
120  private $rawExpiry;
121 
127  private $expiryTime;
128 
130  private $reason;
131 
133  private $isCreateAccountBlocked = false;
134 
141  private $isUserTalkEditBlocked = null;
142 
144  private $isEmailBlocked = false;
145 
147  private $isHardBlock = true;
148 
150  private $isAutoblocking = true;
151 
153  private $isHideUser = false;
154 
165  private $isPartialRaw = false;
166 
168  private $blockRestrictions = [];
169 
171  private $tags = [];
172 
175 
206  public function __construct(
209  BlockPermissionCheckerFactory $blockPermissionCheckerFactory,
212  HookContainer $hookContainer,
216  LoggerInterface $logger,
218  $target,
220  string $expiry,
221  string $reason,
222  array $blockOptions,
223  array $blockRestrictions,
224  array $tags
225  ) {
226  // Process dependencies
227  $options->assertRequiredOptions( self::CONSTRUCTOR_OPTIONS );
228  $this->options = $options;
229  $this->blockRestrictionStore = $blockRestrictionStore;
230  $this->blockPermissionChecker = $blockPermissionCheckerFactory
232  $target,
233  $performer
234  );
235  $this->blockUtils = $blockUtils;
236  $this->hookRunner = new HookRunner( $hookContainer );
237  $this->databaseBlockStore = $databaseBlockStore;
238  $this->userFactory = $userFactory;
239  $this->userEditTracker = $userEditTracker;
240  $this->logger = $logger;
241  $this->titleFactory = $titleFactory;
242  $this->blockActionInfo = $blockActionInfo;
243 
244  // Process block target
245  list( $this->target, $rawTargetType ) = $this->blockUtils->parseBlockTarget( $target );
246  if ( $rawTargetType !== null ) { // Guard against invalid targets
247  $this->targetType = $rawTargetType;
248  } else {
249  $this->targetType = -1;
250  }
251 
252  // Process other block parameters
253  $this->performer = $performer;
254  $this->rawExpiry = $expiry;
255  $this->expiryTime = self::parseExpiryInput( $this->rawExpiry );
256  $this->reason = $reason;
257  $this->blockRestrictions = $blockRestrictions;
258  $this->tags = $tags;
259 
260  // Process blockOptions
261  foreach ( [
262  'isCreateAccountBlocked',
263  'isEmailBlocked',
264  'isHardBlock',
265  'isAutoblocking',
266  ] as $possibleBlockOption ) {
267  if ( isset( $blockOptions[ $possibleBlockOption ] ) ) {
268  $this->$possibleBlockOption = $blockOptions[ $possibleBlockOption ];
269  }
270  }
271 
272  // This needs to be called after $this->blockRestrictions is set, as
273  // $this->isPartial() makes use of it.
274  if (
275  isset( $blockOptions['isPartial'] ) &&
276  !$this->isPartial()
277  ) {
278  $this->isPartialRaw = $blockOptions['isPartial'];
279  }
280 
281  if (
282  !$this->isPartial() ||
283  in_array( NS_USER_TALK, $this->getNamespaceRestrictions() )
284  ) {
285 
286  // It is possible to block user talk edit. User talk edit is:
287  // - always blocked if the config says so;
288  // - otherwise blocked/unblocked if the option was passed in;
289  // - otherwise defaults to not blocked.
290  if ( !$this->options->get( 'BlockAllowsUTEdit' ) ) {
291  $this->isUserTalkEditBlocked = true;
292  } else {
293  $this->isUserTalkEditBlocked = $blockOptions['isUserTalkEditBlocked'] ?? false;
294  }
295 
296  } else {
297 
298  // It is not possible to block user talk edit. If the option
299  // was passed, an error will be thrown in ::placeBlockUnsafe.
300  // Otherwise, set to not blocked.
301  if ( !isset( $blockOptions['isUserTalkEditBlocked'] ) || !$blockOptions['isUserTalkEditBlocked'] ) {
302  $this->isUserTalkEditBlocked = false;
303  }
304 
305  }
306 
307  if (
308  isset( $blockOptions['isHideUser'] ) &&
309  $this->targetType === AbstractBlock::TYPE_USER
310  ) {
311  $this->isHideUser = $blockOptions['isHideUser'];
312  }
313  }
314 
319  public function setLogDeletionFlags( int $flags ): void {
320  $this->logDeletionFlags = $flags;
321  }
322 
335  public static function parseExpiryInput( string $expiry ) {
336  if ( wfIsInfinity( $expiry ) ) {
337  return 'infinity';
338  }
339 
340  // ConvertibleTimestamp::time() used so we can fake the current time in tests
341  $expiry = strtotime( $expiry, ConvertibleTimestamp::time() );
342 
343  if ( $expiry < 0 || $expiry === false ) {
344  return false;
345  }
346 
347  return wfTimestamp( TS_MW, $expiry );
348  }
349 
355  private function isPartial(): bool {
356  return $this->blockRestrictions !== [] || $this->isPartialRaw;
357  }
358 
367  private function configureBlock( $sourceBlock = null ): DatabaseBlock {
368  if ( $sourceBlock === null ) {
369  $block = new DatabaseBlock();
370  } else {
371  $block = clone $sourceBlock;
372  }
373 
374  $isSitewide = !$this->isPartial();
375 
376  $block->setTarget( $this->target );
377  $block->setBlocker( $this->performer->getUser() );
378  $block->setReason( $this->reason );
379  $block->setExpiry( $this->expiryTime );
380  $block->isCreateAccountBlocked( $this->isCreateAccountBlocked );
381  $block->isEmailBlocked( $this->isEmailBlocked );
382  $block->isHardblock( $this->isHardBlock );
383  $block->isAutoblocking( $this->isAutoblocking );
384  $block->isSitewide( $isSitewide );
385  $block->isUsertalkEditAllowed( !$this->isUserTalkEditBlocked );
386  $block->setHideName( $this->isHideUser );
387 
388  if ( $block->getId() === null ) {
389  // Block wasn't inserted into the DB yet
390  $block->setRestrictions( $this->blockRestrictions );
391  } else {
392  // Block is in the DB, we need to set restrictions through a service
393  $block->setRestrictions(
394  $this->blockRestrictionStore->setBlockId(
395  $block->getId(),
396  $this->blockRestrictions
397  )
398  );
399  }
400 
401  return $block;
402  }
403 
412  public function placeBlock( bool $reblock = false ): Status {
413  $priorBlock = DatabaseBlock::newFromTarget( $this->target, null, /*fromPrimary=*/true );
414  $priorHideUser = $priorBlock instanceof DatabaseBlock && $priorBlock->getHideName();
415  if (
416  $this->blockPermissionChecker
417  ->checkBasePermissions(
418  $this->isHideUser || $priorHideUser
419  ) !== true
420  ) {
421  return Status::newFatal( $priorHideUser ? 'cant-see-hidden-user' : 'badaccess-group0' );
422  }
423 
424  $blockCheckResult = $this->blockPermissionChecker->checkBlockPermissions();
425  if ( $blockCheckResult !== true ) {
426  return Status::newFatal( $blockCheckResult );
427  }
428 
429  if (
430  $this->isEmailBlocked &&
431  !$this->blockPermissionChecker->checkEmailPermissions()
432  ) {
433  // TODO: Maybe not ignore the error here?
434  $this->isEmailBlocked = false;
435  }
436 
437  if ( $this->tags !== [] ) {
438  // TODO: Use DI, see T245964
440  $this->tags,
441  $this->performer
442  );
443 
444  if ( !$status->isOK() ) {
445  return $status;
446  }
447  }
448 
449  $status = Status::newGood();
450  foreach ( $this->getPageRestrictions() as $pageRestriction ) {
451  try {
452  $title = $this->titleFactory->newFromTextThrow( $pageRestriction );
453  if ( !$title->exists() ) {
454  $status->fatal( 'cant-block-nonexistent-page', $pageRestriction );
455  }
456  } catch ( MalformedTitleException $e ) {
457  $status->fatal( $e->getMessageObject() );
458  }
459  }
460  if ( !$status->isOK() ) {
461  return $status;
462  }
463 
464  return $this->placeBlockUnsafe( $reblock );
465  }
466 
475  public function placeBlockUnsafe( bool $reblock = false ): Status {
476  $status = $this->blockUtils->validateTarget( $this->target );
477 
478  if ( !$status->isOK() ) {
479  return $status;
480  }
481 
482  if ( $this->isUserTalkEditBlocked === null ) {
483  return Status::newFatal( 'ipb-prevent-user-talk-edit' );
484  }
485 
486  if (
487  // There should be some expiry
488  strlen( $this->rawExpiry ) === 0 ||
489  // can't be a larger string as 50 (it should be a time format in any way)
490  strlen( $this->rawExpiry ) > 50 ||
491  // the time can't be parsed
492  !$this->expiryTime
493  ) {
494  return Status::newFatal( 'ipb_expiry_invalid' );
495  }
496 
497  if ( $this->expiryTime < wfTimestampNow() ) {
498  return Status::newFatal( 'ipb_expiry_old' );
499  }
500 
501  if ( $this->isHideUser ) {
502  if ( $this->isPartial() ) {
503  return Status::newFatal( 'ipb_hide_partial' );
504  }
505 
506  if ( !wfIsInfinity( $this->rawExpiry ) ) {
507  return Status::newFatal( 'ipb_expiry_temp' );
508  }
509 
510  $hideUserContribLimit = $this->options->get( 'HideUserContribLimit' );
511  if (
512  $hideUserContribLimit !== false &&
513  $this->userEditTracker->getUserEditCount( $this->target ) > $hideUserContribLimit
514  ) {
515  return Status::newFatal( 'ipb_hide_invalid', Message::numParam( $hideUserContribLimit ) );
516  }
517  }
518 
519  if ( $this->isPartial() ) {
520  if (
521  $this->blockRestrictions === [] &&
522  !$this->isEmailBlocked &&
523  !$this->isCreateAccountBlocked &&
524  !$this->isUserTalkEditBlocked
525  ) {
526  return Status::newFatal( 'ipb-empty-block' );
527  }
528  }
529 
530  return $this->placeBlockInternal( $reblock );
531  }
532 
541  private function placeBlockInternal( bool $reblock = true ): Status {
542  $block = $this->configureBlock();
543 
544  $denyReason = [ 'hookaborted' ];
545  $legacyUser = $this->userFactory->newFromAuthority( $this->performer );
546  if ( !$this->hookRunner->onBlockIp( $block, $legacyUser, $denyReason ) ) {
547  $status = Status::newGood();
548  foreach ( $denyReason as $key ) {
549  $status->fatal( $key );
550  }
551  return $status;
552  }
553 
554  // Is there a conflicting block?
555  // xxx: there is an identical call at the beginning of ::placeBlock
556  $priorBlock = DatabaseBlock::newFromTarget( $this->target, null, /*fromPrimary=*/true );
557 
558  // T287798: we are blocking an IP that is currently autoblocked
559  // we can ignore the block because ipb_address_unique allows the IP address
560  // be both manually blocked and autoblocked
561  // this will work as long as DatabaseBlock::newLoad prefers manual IP blocks
562  // over autoblocks
563  if ( $priorBlock !== null
564  && $priorBlock->getType() === AbstractBlock::TYPE_AUTO
565  && $this->targetType === AbstractBlock::TYPE_IP
566  ) {
567  $priorBlock = null;
568  }
569 
570  $isReblock = false;
571  if ( $priorBlock !== null ) {
572  // Reblock only if the caller wants so
573  if ( !$reblock ) {
574  return Status::newFatal( 'ipb_already_blocked', $block->getTargetName() );
575  }
576 
577  if ( $block->equals( $priorBlock ) ) {
578  // Block settings are equal => user is already blocked
579  return Status::newFatal( 'ipb_already_blocked', $block->getTargetName() );
580  }
581 
582  $currentBlock = $this->configureBlock( $priorBlock );
583  $this->databaseBlockStore->updateBlock( $currentBlock ); // TODO handle failure
584  $isReblock = true;
585  $block = $currentBlock;
586  } else {
587  // Try to insert block.
588  $insertStatus = $this->databaseBlockStore->insertBlock( $block );
589  if ( !$insertStatus ) {
590  $this->logger->warning( 'Block could not be inserted. No existing block was found.' );
591  return Status::newFatal( 'ipb-block-not-found', $block->getTargetName() );
592  }
593  }
594 
595  // Set *_deleted fields if requested
596  if ( $this->isHideUser ) {
597  // This should only be the case of $this->target is a user, so we can
598  // safely call ->getId()
599  RevisionDeleteUser::suppressUserName( $this->target->getName(), $this->target->getId() );
600  }
601 
602  $this->hookRunner->onBlockIpComplete( $block, $legacyUser, $priorBlock );
603 
604  // DatabaseBlock constructor sanitizes certain block options on insert
605  $this->isEmailBlocked = $block->isEmailBlocked();
606  $this->isAutoblocking = $block->isAutoblocking();
607 
608  $this->log( $block, $isReblock );
609 
610  return Status::newGood( $block );
611  }
612 
620  private function getNamespaceRestrictions(): array {
621  $namespaceRestrictions = [];
622  foreach ( $this->blockRestrictions as $restriction ) {
623  if ( $restriction instanceof NamespaceRestriction ) {
624  $namespaceRestrictions[] = $restriction->getValue();
625  }
626  }
627  return $namespaceRestrictions;
628  }
629 
637  private function getPageRestrictions(): array {
638  $pageRestrictions = [];
639  foreach ( $this->blockRestrictions as $restriction ) {
640  if ( $restriction instanceof PageRestriction ) {
641  $pageRestrictions[] = $restriction->getTitle()->getFullText();
642  }
643  }
644  return $pageRestrictions;
645  }
646 
654  private function getActionRestrictions(): array {
655  $actionRestrictions = [];
656  foreach ( $this->blockRestrictions as $restriction ) {
657  if ( $restriction instanceof ActionRestriction ) {
658  $actionRestrictions[] = $this->blockActionInfo->getActionFromId( $restriction->getValue() );
659  }
660  }
661  return $actionRestrictions;
662  }
663 
671  private function constructLogParams(): array {
672  $logExpiry = wfIsInfinity( $this->rawExpiry ) ? 'infinity' : $this->rawExpiry;
673  $logParams = [
674  '5::duration' => $logExpiry,
675  '6::flags' => $this->blockLogFlags(),
676  'sitewide' => !$this->isPartial()
677  ];
678 
679  if ( $this->isPartial() ) {
680  $pageRestrictions = $this->getPageRestrictions();
681  $namespaceRestrictions = $this->getNamespaceRestrictions();
682  $actionRestriction = $this->getActionRestrictions();
683 
684  if ( count( $pageRestrictions ) > 0 ) {
685  $logParams['7::restrictions']['pages'] = $pageRestrictions;
686  }
687  if ( count( $namespaceRestrictions ) > 0 ) {
688  $logParams['7::restrictions']['namespaces'] = $namespaceRestrictions;
689  }
690  if ( count( $actionRestriction ) ) {
691  $logParams['7::restrictions']['actions'] = $actionRestriction;
692  }
693  }
694  return $logParams;
695  }
696 
703  private function log( DatabaseBlock $block, bool $isReblock ) {
704  $logType = $this->isHideUser ? 'suppress' : 'block';
705  $logAction = $isReblock ? 'reblock' : 'block';
706 
707  $logEntry = new ManualLogEntry( $logType, $logAction );
708  $logEntry->setTarget( Title::makeTitle( NS_USER, $this->target ) );
709  $logEntry->setComment( $this->reason );
710  $logEntry->setPerformer( $this->performer->getUser() );
711  $logEntry->setParameters( $this->constructLogParams() );
712  // Relate log ID to block ID (T27763)
713  $logEntry->setRelations( [ 'ipb_id' => $block->getId() ] );
714  $logEntry->addTags( $this->tags );
715  if ( $this->logDeletionFlags !== null ) {
716  $logEntry->setDeleted( $this->logDeletionFlags );
717  }
718  $logId = $logEntry->insert();
719  $logEntry->publish( $logId );
720  }
721 
728  private function blockLogFlags(): string {
729  $flags = [];
730 
731  if ( $this->targetType != AbstractBlock::TYPE_USER && !$this->isHardBlock ) {
732  // For grepping: message block-log-flags-anononly
733  $flags[] = 'anononly';
734  }
735 
736  if ( $this->isCreateAccountBlocked ) {
737  // For grepping: message block-log-flags-nocreate
738  $flags[] = 'nocreate';
739  }
740 
741  if ( $this->targetType == AbstractBlock::TYPE_USER && !$this->isAutoblocking ) {
742  // For grepping: message block-log-flags-noautoblock
743  $flags[] = 'noautoblock';
744  }
745 
746  if ( $this->isEmailBlocked ) {
747  // For grepping: message block-log-flags-noemail
748  $flags[] = 'noemail';
749  }
750 
751  if ( $this->options->get( 'BlockAllowsUTEdit' ) && $this->isUserTalkEditBlocked ) {
752  // For grepping: message block-log-flags-nousertalk
753  $flags[] = 'nousertalk';
754  }
755 
756  if ( $this->isHideUser ) {
757  // For grepping: message block-log-flags-hiddenname
758  $flags[] = 'hiddenname';
759  }
760 
761  return implode( ',', $flags );
762  }
763 }
MediaWiki\Block\BlockUser\isPartial
isPartial()
Is the to-be-placed block partial?
Definition: BlockUser.php:355
Message\numParam
static numParam( $num)
Definition: Message.php:1085
MediaWiki\Block\BlockUser\getNamespaceRestrictions
getNamespaceRestrictions()
Build namespace restrictions array from $this->blockRestrictions.
Definition: BlockUser.php:620
MediaWiki\Block\BlockPermissionCheckerFactory
Factory class for BlockPermissionChecker.
Definition: BlockPermissionCheckerFactory.php:33
StatusValue\newFatal
static newFatal( $message,... $parameters)
Factory function for fatal errors.
Definition: StatusValue.php:70
MediaWiki\Block
Definition: AbstractBlock.php:21
MediaWiki\Block\BlockUser\__construct
__construct(ServiceOptions $options, BlockRestrictionStore $blockRestrictionStore, BlockPermissionCheckerFactory $blockPermissionCheckerFactory, BlockUtils $blockUtils, BlockActionInfo $blockActionInfo, HookContainer $hookContainer, DatabaseBlockStore $databaseBlockStore, UserFactory $userFactory, UserEditTracker $userEditTracker, LoggerInterface $logger, TitleFactory $titleFactory, $target, Authority $performer, string $expiry, string $reason, array $blockOptions, array $blockRestrictions, array $tags)
Definition: BlockUser.php:206
MediaWiki\Block\BlockUser\$rawExpiry
string $rawExpiry
Expiry of the to-be-placed block exactly as it was passed to the constructor.
Definition: BlockUser.php:120
MediaWiki\Block\BlockUser\$hookRunner
HookRunner $hookRunner
Definition: BlockUser.php:87
MediaWiki\Block\BlockUser\getActionRestrictions
getActionRestrictions()
Build an array of actions from $this->blockRestrictions.
Definition: BlockUser.php:654
MediaWiki\Block\BlockUser\$userEditTracker
UserEditTracker $userEditTracker
Definition: BlockUser.php:96
MediaWiki\Block\BlockUser
Handles the backend logic of blocking users.
Definition: BlockUser.php:51
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1691
MediaWiki\Block\BlockUser\$blockUtils
BlockUtils $blockUtils
Definition: BlockUser.php:84
MediaWiki\Block\BlockUtils
Backend class for blocking utils.
Definition: BlockUtils.php:45
MalformedTitleException\getMessageObject
getMessageObject()
Definition: MalformedTitleException.php:86
MediaWiki\Block\BlockUser\$isEmailBlocked
bool $isEmailBlocked
Definition: BlockUser.php:144
MediaWiki\Block\BlockUser\$tags
string[] $tags
Definition: BlockUser.php:171
MediaWiki\Block\BlockUser\log
log(DatabaseBlock $block, bool $isReblock)
Log the block to Special:Log.
Definition: BlockUser.php:703
MediaWiki\Block\BlockUser\$blockRestrictions
AbstractRestriction[] $blockRestrictions
Definition: BlockUser.php:168
MediaWiki\Block\DatabaseBlockStore
Definition: DatabaseBlockStore.php:47
MediaWiki\Block\BlockUser\$target
UserIdentity string null $target
Target of the block.
Definition: BlockUser.php:60
MediaWiki\Block\BlockUser\placeBlockInternal
placeBlockInternal(bool $reblock=true)
Places a block without any sort of sanity/permission checks, hooks can still abort the block through,...
Definition: BlockUser.php:541
MediaWiki\User\UserIdentity
Interface for objects representing user identity.
Definition: UserIdentity.php:39
MediaWiki\Block\BlockUser\$isUserTalkEditBlocked
bool null $isUserTalkEditBlocked
This may be null when an invalid option was passed to the constructor.
Definition: BlockUser.php:141
MediaWiki\Block\BlockUser\$isHardBlock
bool $isHardBlock
Definition: BlockUser.php:147
Status
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition: Status.php:44
MediaWiki\Block\DatabaseBlock
A DatabaseBlock (unlike a SystemBlock) is stored in the database, may give rise to autoblocks and may...
Definition: DatabaseBlock.php:52
MediaWiki\Block\BlockUser\blockLogFlags
blockLogFlags()
Return a comma-delimited list of flags to be passed to the log reader for this block,...
Definition: BlockUser.php:728
MediaWiki\Block\BlockUser\$isCreateAccountBlocked
bool $isCreateAccountBlocked
Definition: BlockUser.php:133
MediaWiki\Config\ServiceOptions
A class for passing options to services.
Definition: ServiceOptions.php:27
MediaWiki\Block\BlockUser\getPageRestrictions
getPageRestrictions()
Build an array of page restrictions from $this->blockRestrictions.
Definition: BlockUser.php:637
ChangeTags
Definition: ChangeTags.php:32
MediaWiki\Block\BlockUser\$databaseBlockStore
DatabaseBlockStore $databaseBlockStore
Definition: BlockUser.php:90
MediaWiki\Block\BlockUser\$blockActionInfo
BlockActionInfo $blockActionInfo
Definition: BlockUser.php:105
MediaWiki\Block\BlockUser\$performer
Authority $performer
Performer of the block.
Definition: BlockUser.php:72
MediaWiki\Block\BlockUser\parseExpiryInput
static parseExpiryInput(string $expiry)
Convert a submitted expiry time, which may be relative ("2 weeks", etc) or absolute ("24 May 2034",...
Definition: BlockUser.php:335
$title
$title
Definition: testCompression.php:38
MediaWiki\Block\BlockUser\$userFactory
UserFactory $userFactory
Definition: BlockUser.php:93
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:651
MediaWiki\Block\BlockUser\$titleFactory
TitleFactory $titleFactory
Definition: BlockUser.php:102
wfTimestampNow
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
Definition: GlobalFunctions.php:1720
MediaWiki\Block\BlockPermissionCheckerFactory\newBlockPermissionChecker
newBlockPermissionChecker( $target, Authority $performer)
Definition: BlockPermissionCheckerFactory.php:65
MediaWiki\Block\BlockUser\$logDeletionFlags
int null $logDeletionFlags
Definition: BlockUser.php:174
MediaWiki\Permissions\Authority
This interface represents the authority associated the current execution context, such as a web reque...
Definition: Authority.php:37
MediaWiki\Block\BlockPermissionChecker
Block permissions.
Definition: BlockPermissionChecker.php:38
MediaWiki\Block\DatabaseBlock\newFromTarget
static newFromTarget( $specificTarget, $vagueTarget=null, $fromPrimary=false)
Given a target and the target's type, get an existing block object if possible.
Definition: DatabaseBlock.php:891
ChangeTags\canAddTagsAccompanyingChange
static canAddTagsAccompanyingChange(array $tags, Authority $performer=null)
Is it OK to allow the user to apply all the specified tags at the same time as they edit/make the cha...
Definition: ChangeTags.php:625
MediaWiki\Block\BlockUser\$logger
LoggerInterface $logger
Definition: BlockUser.php:99
StatusValue\newGood
static newGood( $value=null)
Factory function for good results.
Definition: StatusValue.php:82
MediaWiki\Block\BlockUser\CONSTRUCTOR_OPTIONS
const CONSTRUCTOR_OPTIONS
Definition: BlockUser.php:110
wfIsInfinity
wfIsInfinity( $str)
Determine input string is represents as infinity.
Definition: GlobalFunctions.php:2547
MediaWiki\Block\BlockUser\$isPartialRaw
bool $isPartialRaw
Flag that needs to be true when the to-be-created block allows all editing, but does not allow some o...
Definition: BlockUser.php:165
MediaWiki\Block\BlockUser\placeBlockUnsafe
placeBlockUnsafe(bool $reblock=false)
Places a block without any sort of permissions checks.
Definition: BlockUser.php:475
MediaWiki\Block\Block\TYPE_AUTO
const TYPE_AUTO
Definition: Block.php:44
MediaWiki\Block\Block\TYPE_USER
const TYPE_USER
Definition: Block.php:41
MediaWiki\Block\BlockActionInfo
Defines the actions that can be blocked by a partial block.
Definition: BlockActionInfo.php:40
NS_USER
const NS_USER
Definition: Defines.php:66
MediaWiki\Block\BlockUser\$expiryTime
string bool $expiryTime
Parsed expiry.
Definition: BlockUser.php:127
RevisionDeleteUser
Backend functions for suppressing and unsuppressing all references to a given user,...
Definition: RevisionDeleteUser.php:35
MediaWiki\Block\Restriction\AbstractRestriction
Definition: AbstractRestriction.php:25
MediaWiki\Block\BlockUser\constructLogParams
constructLogParams()
Prepare $logParams.
Definition: BlockUser.php:671
MediaWiki\Block\Restriction\NamespaceRestriction
Definition: NamespaceRestriction.php:25
MediaWiki\Block\DatabaseBlock\getId
getId()
Get the block ID.int|null
Definition: DatabaseBlock.php:775
Title
Represents a title within MediaWiki.
Definition: Title.php:48
MediaWiki\Block\BlockUser\$isHideUser
bool $isHideUser
Definition: BlockUser.php:153
MalformedTitleException
MalformedTitleException is thrown when a TitleParser is unable to parse a title string.
Definition: MalformedTitleException.php:26
MediaWiki\User\UserEditTracker
Track info about user edit counts and timings.
Definition: UserEditTracker.php:21
MediaWiki\Block\BlockUser\placeBlock
placeBlock(bool $reblock=false)
Places a block with checking permissions.
Definition: BlockUser.php:412
MediaWiki\Block\Restriction\PageRestriction
Definition: PageRestriction.php:25
MediaWiki\Block\BlockUser\$isAutoblocking
bool $isAutoblocking
Definition: BlockUser.php:150
MediaWiki\Block\BlockUser\$blockPermissionChecker
BlockPermissionChecker $blockPermissionChecker
Definition: BlockUser.php:81
MediaWiki\Block\BlockUser\$targetType
int $targetType
One of AbstractBlock::TYPE_* constants.
Definition: BlockUser.php:69
TitleFactory
Creates Title objects.
Definition: TitleFactory.php:35
Message
The Message class deals with fetching and processing of interface message into a variety of formats.
Definition: Message.php:138
NS_USER_TALK
const NS_USER_TALK
Definition: Defines.php:67
ManualLogEntry
Class for creating new log entries and inserting them into the database.
Definition: ManualLogEntry.php:44
MediaWiki\Block\BlockUser\$options
ServiceOptions $options
Definition: BlockUser.php:75
MediaWiki\HookContainer\HookContainer
HookContainer class.
Definition: HookContainer.php:45
RevisionDeleteUser\suppressUserName
static suppressUserName( $name, $userId, IDatabase $dbw=null)
Definition: RevisionDeleteUser.php:173
MediaWiki\Block\AbstractBlock\getHideName
getHideName()
Get whether the block hides the target's username.
Definition: AbstractBlock.php:174
MediaWiki\HookContainer\HookRunner
This class provides an implementation of the core hook interfaces, forwarding hook calls to HookConta...
Definition: HookRunner.php:558
MediaWiki\Block\BlockUser\setLogDeletionFlags
setLogDeletionFlags(int $flags)
Definition: BlockUser.php:319
MediaWiki\Block\BlockUser\configureBlock
configureBlock( $sourceBlock=null)
Configure DatabaseBlock according to class properties.
Definition: BlockUser.php:367
MediaWiki\Block\Restriction\ActionRestriction
Restriction for partial blocks of actions.
Definition: ActionRestriction.php:30
MediaWiki\User\UserFactory
Creates User objects.
Definition: UserFactory.php:41
MediaWiki\Block\BlockUser\$reason
string $reason
Definition: BlockUser.php:130
MediaWiki\Block\Block\TYPE_IP
const TYPE_IP
Definition: Block.php:42
MediaWiki\Config\ServiceOptions\assertRequiredOptions
assertRequiredOptions(array $expectedKeys)
Assert that the list of options provided in this instance exactly match $expectedKeys,...
Definition: ServiceOptions.php:71
MediaWiki\Block\BlockRestrictionStore
Definition: BlockRestrictionStore.php:35
MediaWiki\Block\BlockUser\$blockRestrictionStore
BlockRestrictionStore $blockRestrictionStore
Definition: BlockUser.php:78