MediaWiki  master
BlockManager.php
Go to the documentation of this file.
1 <?php
21 namespace MediaWiki\Block;
22 
23 use DateTime;
24 use DateTimeZone;
25 use LogicException;
32 use Message;
33 use MWCryptHash;
34 use Psr\Log\LoggerInterface;
35 use User;
36 use WebRequest;
37 use WebResponse;
38 use Wikimedia\IPSet;
39 use Wikimedia\IPUtils;
40 
47 class BlockManager {
50 
52  private $userFactory;
53 
55  private $options;
56 
60  public const CONSTRUCTOR_OPTIONS = [
61  'ApplyIpBlocksToXff',
62  'CookieSetOnAutoblock',
63  'CookieSetOnIpBlock',
64  'DnsBlacklistUrls',
65  'EnableDnsBlacklist',
66  'ProxyList',
67  'ProxyWhitelist',
68  'SecretKey',
69  'SoftBlockRanges',
70  ];
71 
73  private $logger;
74 
76  private $hookRunner;
77 
85  public function __construct(
89  LoggerInterface $logger,
90  HookContainer $hookContainer
91  ) {
92  $options->assertRequiredOptions( self::CONSTRUCTOR_OPTIONS );
93  $this->options = $options;
94  $this->permissionManager = $permissionManager;
95  $this->userFactory = $userFactory;
96  $this->logger = $logger;
97  $this->hookRunner = new HookRunner( $hookContainer );
98  }
99 
132  public function getUserBlock(
133  UserIdentity $user,
134  $request,
135  $fromReplica,
136  $disableIpBlockExemptChecking = false
137  ) {
138  $fromPrimary = !$fromReplica;
139  $ip = null;
140 
141  // If this is the global user, they may be affected by IP blocks (case #1),
142  // or they may be exempt (case #2). If affected, look for additional blocks
143  // against the IP address and referenced in a cookie.
144  $checkIpBlocks = $request &&
145  // Because calling getBlock within Autopromote leads back to here,
146  // thus causing a infinite recursion. We fix this by not checking for
147  // ipblock-exempt when calling getBlock within Autopromote.
148  // See T270145.
149  !$disableIpBlockExemptChecking &&
150  !$this->permissionManager->userHasRight( $user, 'ipblock-exempt' );
151 
152  if ( $request && $checkIpBlocks ) {
153 
154  // Case #1: checking the global user, including IP blocks
155  $ip = $request->getIP();
156  $isAnon = !$user->isRegistered();
157 
158  $xff = $request->getHeader( 'X-Forwarded-For' );
159 
160  // TODO: remove dependency on DatabaseBlock (T221075)
161  $blocks = array_merge(
162  DatabaseBlock::newListFromTarget( $user, $ip, $fromPrimary ),
163  $this->getSystemIpBlocks( $ip, $isAnon ),
164  $this->getXffBlocks( $ip, $xff, $isAnon, $fromPrimary ),
165  $this->getCookieBlock( $user, $request )
166  );
167  } else {
168 
169  // Case #2: checking the global user, but they are exempt from IP blocks
170  // and cookie blocks, so we only check for a user account block.
171  // Case #3: checking whether another user's account is blocked.
172  // TODO: remove dependency on DatabaseBlock (T221075)
173  $blocks = DatabaseBlock::newListFromTarget( $user, null, $fromPrimary );
174 
175  }
176 
177  $block = $this->createGetBlockResult( $ip, $blocks );
178 
179  $legacyUser = $this->userFactory->newFromUserIdentity( $user );
180  $this->hookRunner->onGetUserBlock( clone $legacyUser, $ip, $block );
181 
182  return $block;
183  }
184 
190  private function createGetBlockResult( ?string $ip, array $blocks ): ?AbstractBlock {
191  // Filter out any duplicated blocks, e.g. from the cookie
192  $blocks = $this->getUniqueBlocks( $blocks );
193 
194  if ( count( $blocks ) === 0 ) {
195  return null;
196  } elseif ( count( $blocks ) === 1 ) {
197  return $blocks[ 0 ];
198  } else {
199  // @phan-suppress-next-line SecurityCheck-DoubleEscaped
200  return new CompositeBlock( [
201  'address' => $ip,
202  'reason' => new Message( 'blockedtext-composite-reason' ),
203  'originalBlocks' => $blocks,
204  ] );
205  }
206  }
207 
217  public function getIpBlock( string $ip, bool $fromReplica ): ?AbstractBlock {
218  if ( !IPUtils::isValid( $ip ) ) {
219  return null;
220  }
221 
222  $blocks = array_merge(
223  DatabaseBlock::newListFromTarget( $ip, $ip, !$fromReplica ),
224  $this->getSystemIpBlocks( $ip, true )
225  );
226 
227  return $this->createGetBlockResult( $ip, $blocks );
228  }
229 
237  private function getCookieBlock( UserIdentity $user, WebRequest $request ): array {
238  $cookieBlock = $this->getBlockFromCookieValue( $user, $request );
239 
240  return $cookieBlock instanceof DatabaseBlock ? [ $cookieBlock ] : [];
241  }
242 
250  private function getSystemIpBlocks( string $ip, bool $isAnon ): array {
251  $blocks = [];
252 
253  // Proxy blocking
254  if ( !in_array( $ip, $this->options->get( 'ProxyWhitelist' ) ) ) {
255  // Local list
256  if ( $this->isLocallyBlockedProxy( $ip ) ) {
257  // @phan-suppress-next-line SecurityCheck-DoubleEscaped
258  $blocks[] = new SystemBlock( [
259  'reason' => new Message( 'proxyblockreason' ),
260  'address' => $ip,
261  'systemBlock' => 'proxy',
262  ] );
263  } elseif ( $isAnon && $this->isDnsBlacklisted( $ip ) ) {
264  // @phan-suppress-next-line SecurityCheck-DoubleEscaped
265  $blocks[] = new SystemBlock( [
266  'reason' => new Message( 'sorbsreason' ),
267  'address' => $ip,
268  'anonOnly' => true,
269  'systemBlock' => 'dnsbl',
270  ] );
271  }
272  }
273 
274  // Soft blocking
275  if ( $isAnon && IPUtils::isInRanges( $ip, $this->options->get( 'SoftBlockRanges' ) ) ) {
276  // @phan-suppress-next-line SecurityCheck-DoubleEscaped
277  $blocks[] = new SystemBlock( [
278  'address' => $ip,
279  'reason' => new Message( 'softblockrangesreason', [ $ip ] ),
280  'anonOnly' => true,
281  'systemBlock' => 'wgSoftBlockRanges',
282  ] );
283  }
284 
285  return $blocks;
286  }
287 
299  private function getXffBlocks( string $ip, string $xff, bool $isAnon, bool $fromPrimary ): array {
300  // (T25343) Apply IP blocks to the contents of XFF headers, if enabled
301  if ( $this->options->get( 'ApplyIpBlocksToXff' )
302  && !in_array( $ip, $this->options->get( 'ProxyWhitelist' ) )
303  ) {
304  $xff = array_map( 'trim', explode( ',', $xff ) );
305  $xff = array_diff( $xff, [ $ip ] );
306  // TODO: remove dependency on DatabaseBlock (T221075)
307  return DatabaseBlock::getBlocksForIPList( $xff, $isAnon, $fromPrimary );
308  }
309 
310  return [];
311  }
312 
323  private function getUniqueBlocks( array $blocks ) {
324  $systemBlocks = [];
325  $databaseBlocks = [];
326 
327  foreach ( $blocks as $block ) {
328  if ( $block instanceof SystemBlock ) {
329  $systemBlocks[] = $block;
330  } elseif ( $block->getType() === DatabaseBlock::TYPE_AUTO ) {
332  '@phan-var DatabaseBlock $block';
333  if ( !isset( $databaseBlocks[$block->getParentBlockId()] ) ) {
334  $databaseBlocks[$block->getParentBlockId()] = $block;
335  }
336  } else {
337  $databaseBlocks[$block->getId()] = $block;
338  }
339  }
340 
341  return array_values( array_merge( $systemBlocks, $databaseBlocks ) );
342  }
343 
355  private function getBlockFromCookieValue(
356  UserIdentity $user,
357  WebRequest $request
358  ) {
359  $cookieValue = $request->getCookie( 'BlockID' );
360  if ( $cookieValue === null ) {
361  return false;
362  }
363 
364  $blockCookieId = $this->getIdFromCookieValue( $cookieValue );
365  if ( $blockCookieId !== null ) {
366  // TODO: remove dependency on DatabaseBlock (T221075)
367  $block = DatabaseBlock::newFromID( $blockCookieId );
368  if (
369  $block instanceof DatabaseBlock &&
370  $this->shouldApplyCookieBlock( $block, !$user->isRegistered() )
371  ) {
372  return $block;
373  }
374  }
375 
376  return false;
377  }
378 
386  private function shouldApplyCookieBlock( DatabaseBlock $block, $isAnon ) {
387  if ( !$block->isExpired() ) {
388  switch ( $block->getType() ) {
391  // If block is type IP or IP range, load only
392  // if user is not logged in (T152462)
393  return $isAnon &&
394  $this->options->get( 'CookieSetOnIpBlock' );
396  return $block->isAutoblocking() &&
397  $this->options->get( 'CookieSetOnAutoblock' );
398  default:
399  return false;
400  }
401  }
402  return false;
403  }
404 
411  private function isLocallyBlockedProxy( $ip ) {
412  $proxyList = $this->options->get( 'ProxyList' );
413  if ( !$proxyList ) {
414  return false;
415  }
416 
417  if ( !is_array( $proxyList ) ) {
418  // Load values from the specified file
419  $proxyList = array_map( 'trim', file( $proxyList ) );
420  }
421 
422  $proxyListIPSet = new IPSet( $proxyList );
423  return $proxyListIPSet->match( $ip );
424  }
425 
433  public function isDnsBlacklisted( $ip, $checkAllowed = false ) {
434  if ( !$this->options->get( 'EnableDnsBlacklist' ) ||
435  ( $checkAllowed && in_array( $ip, $this->options->get( 'ProxyWhitelist' ) ) )
436  ) {
437  return false;
438  }
439 
440  return $this->inDnsBlacklist( $ip, $this->options->get( 'DnsBlacklistUrls' ) );
441  }
442 
450  private function inDnsBlacklist( $ip, array $bases ) {
451  $found = false;
452  // @todo FIXME: IPv6 ??? (https://bugs.php.net/bug.php?id=33170)
453  if ( IPUtils::isIPv4( $ip ) ) {
454  // Reverse IP, T23255
455  $ipReversed = implode( '.', array_reverse( explode( '.', $ip ) ) );
456 
457  foreach ( $bases as $base ) {
458  // Make hostname
459  // If we have an access key, use that too (ProjectHoneypot, etc.)
460  $basename = $base;
461  if ( is_array( $base ) ) {
462  if ( count( $base ) >= 2 ) {
463  // Access key is 1, base URL is 0
464  $hostname = "{$base[1]}.$ipReversed.{$base[0]}";
465  } else {
466  $hostname = "$ipReversed.{$base[0]}";
467  }
468  $basename = $base[0];
469  } else {
470  $hostname = "$ipReversed.$base";
471  }
472 
473  // Send query
474  $ipList = $this->checkHost( $hostname );
475 
476  if ( $ipList ) {
477  $this->logger->info(
478  'Hostname {hostname} is {ipList}, it\'s a proxy says {basename}!',
479  [
480  'hostname' => $hostname,
481  'ipList' => $ipList[0],
482  'basename' => $basename,
483  ]
484  );
485  $found = true;
486  break;
487  }
488 
489  $this->logger->debug( "Requested $hostname, not found in $basename." );
490  }
491  }
492 
493  return $found;
494  }
495 
502  protected function checkHost( $hostname ) {
503  return gethostbynamel( $hostname );
504  }
505 
525  public function trackBlockWithCookie( User $user, WebResponse $response ) {
526  $request = $user->getRequest();
527 
528  if ( $request->getCookie( 'BlockID' ) !== null ) {
529  $cookieBlock = $this->getBlockFromCookieValue( $user, $request );
530  if ( $cookieBlock && $this->shouldApplyCookieBlock( $cookieBlock, $user->isAnon() ) ) {
531  return;
532  }
533  // The block pointed to by the cookie is invalid or should not be tracked.
534  $this->clearBlockCookie( $response );
535  }
536 
537  if ( !$user->isSafeToLoad() ) {
538  // Prevent a circular dependency by not allowing this method to be called
539  // before or while the user is being loaded.
540  // E.g. User > BlockManager > Block > Message > getLanguage > User.
541  // See also T180050 and T226777.
542  throw new LogicException( __METHOD__ . ' requires a loaded User object' );
543  }
544  if ( $response->headersSent() ) {
545  throw new LogicException( __METHOD__ . ' must be called pre-send' );
546  }
547 
548  $block = $user->getBlock();
549  $isAnon = $user->isAnon();
550 
551  if ( $block ) {
552  if ( $block instanceof CompositeBlock ) {
553  // TODO: Improve on simply tracking the first trackable block (T225654)
554  foreach ( $block->getOriginalBlocks() as $originalBlock ) {
555  if ( $this->shouldTrackBlockWithCookie( $originalBlock, $isAnon ) ) {
556  '@phan-var DatabaseBlock $originalBlock';
557  $this->setBlockCookie( $originalBlock, $response );
558  return;
559  }
560  }
561  } else {
562  if ( $this->shouldTrackBlockWithCookie( $block, $isAnon ) ) {
563  '@phan-var DatabaseBlock $block';
564  $this->setBlockCookie( $block, $response );
565  }
566  }
567  }
568  }
569 
580  public function setBlockCookie( DatabaseBlock $block, WebResponse $response ) {
581  // Calculate the default expiry time.
582  $maxExpiryTime = wfTimestamp( TS_MW, (int)wfTimestamp() + ( 24 * 60 * 60 ) );
583 
584  // Use the block's expiry time only if it's less than the default.
585  $expiryTime = $block->getExpiry();
586  if ( $expiryTime === 'infinity' || $expiryTime > $maxExpiryTime ) {
587  $expiryTime = $maxExpiryTime;
588  }
589 
590  // Set the cookie. Reformat the MediaWiki datetime as a Unix timestamp for the cookie.
591  $expiryValue = DateTime::createFromFormat(
592  'YmdHis',
593  $expiryTime,
594  new DateTimeZone( 'UTC' )
595  )->format( 'U' );
596  $cookieOptions = [ 'httpOnly' => false ];
597  $cookieValue = $this->getCookieValue( $block );
598  $response->setCookie( 'BlockID', $cookieValue, $expiryValue, $cookieOptions );
599  }
600 
608  private function shouldTrackBlockWithCookie( AbstractBlock $block, $isAnon ) {
609  if ( $block instanceof DatabaseBlock ) {
610  switch ( $block->getType() ) {
613  return $isAnon && $this->options->get( 'CookieSetOnIpBlock' );
615  return !$isAnon &&
616  $this->options->get( 'CookieSetOnAutoblock' ) &&
617  $block->isAutoblocking();
618  default:
619  return false;
620  }
621  }
622  return false;
623  }
624 
631  public static function clearBlockCookie( WebResponse $response ) {
632  $response->clearCookie( 'BlockID', [ 'httpOnly' => false ] );
633  }
634 
645  public function getIdFromCookieValue( $cookieValue ) {
646  // The cookie value must start with a number
647  if ( !is_numeric( substr( $cookieValue, 0, 1 ) ) ) {
648  return null;
649  }
650 
651  // Extract the ID prefix from the cookie value (may be the whole value, if no bang found).
652  $bangPos = strpos( $cookieValue, '!' );
653  $id = ( $bangPos === false ) ? $cookieValue : substr( $cookieValue, 0, $bangPos );
654  if ( !$this->options->get( 'SecretKey' ) ) {
655  // If there's no secret key, just use the ID as given.
656  return (int)$id;
657  }
658  $storedHmac = substr( $cookieValue, $bangPos + 1 );
659  $calculatedHmac = MWCryptHash::hmac( $id, $this->options->get( 'SecretKey' ), false );
660  if ( $calculatedHmac === $storedHmac ) {
661  return (int)$id;
662  } else {
663  return null;
664  }
665  }
666 
678  public function getCookieValue( DatabaseBlock $block ) {
679  $id = $block->getId();
680  if ( !$this->options->get( 'SecretKey' ) ) {
681  // If there's no secret key, don't append a HMAC.
682  return $id;
683  }
684  $hmac = MWCryptHash::hmac( $id, $this->options->get( 'SecretKey' ), false );
685  $cookieValue = $id . '!' . $hmac;
686  return $cookieValue;
687  }
688 
689 }
MediaWiki\Block\BlockManager\$logger
LoggerInterface $logger
Definition: BlockManager.php:73
MediaWiki\Block\BlockManager\trackBlockWithCookie
trackBlockWithCookie(User $user, WebResponse $response)
Set the 'BlockID' cookie depending on block type and user authentication status.
Definition: BlockManager.php:525
MediaWiki\Block\BlockManager\getXffBlocks
getXffBlocks(string $ip, string $xff, bool $isAnon, bool $fromPrimary)
If $wgApplyIpBlocksToXff is truthy and the IP that the user is accessing the wiki from is not in $wgP...
Definition: BlockManager.php:299
MWCryptHash\hmac
static hmac( $data, $key, $raw=true)
Generate an acceptably unstable one-way-hmac of some text making use of the best hash algorithm that ...
Definition: MWCryptHash.php:106
User\isAnon
isAnon()
Get whether the user is anonymous.
Definition: User.php:2538
MediaWiki\Block
Definition: AbstractBlock.php:21
MediaWiki\Block\BlockManager\getIpBlock
getIpBlock(string $ip, bool $fromReplica)
Get the blocks that apply to an IP address.
Definition: BlockManager.php:217
MediaWiki\Block\BlockManager
A service class for checking blocks.
Definition: BlockManager.php:47
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1649
MediaWiki\Block\DatabaseBlock\getType
getType()
Get the type of target for this particular block.int|null AbstractBlock::TYPE_ constant,...
Definition: DatabaseBlock.php:969
MediaWiki\Block\BlockManager\getCookieBlock
getCookieBlock(UserIdentity $user, WebRequest $request)
Get the cookie block, if there is one.
Definition: BlockManager.php:237
MediaWiki\Block\BlockManager\shouldApplyCookieBlock
shouldApplyCookieBlock(DatabaseBlock $block, $isAnon)
Check if the block loaded from the cookie should be applied.
Definition: BlockManager.php:386
MediaWiki\Block\BlockManager\isDnsBlacklisted
isDnsBlacklisted( $ip, $checkAllowed=false)
Whether the given IP is in a DNS blacklist.
Definition: BlockManager.php:433
WebResponse\setCookie
setCookie( $name, $value, $expire=0, $options=[])
Set the browser cookie.
Definition: WebResponse.php:142
User\isSafeToLoad
isSafeToLoad()
Test if it's safe to load this User object.
Definition: User.php:347
MWCryptHash
Definition: MWCryptHash.php:26
$base
$base
Definition: generateLocalAutoload.php:11
User\getBlock
getBlock( $freshness=self::READ_NORMAL, $disableIpBlockExemptChecking=false)
Get the block affecting the user, or null if the user is not blocked.
Definition: User.php:1731
MediaWiki\User\UserIdentity
Interface for objects representing user identity.
Definition: UserIdentity.php:39
User\getRequest
getRequest()
Get the WebRequest object to use with this object.
Definition: User.php:2629
MediaWiki\Block\DatabaseBlock
A DatabaseBlock (unlike a SystemBlock) is stored in the database, may give rise to autoblocks and may...
Definition: DatabaseBlock.php:51
WebResponse\clearCookie
clearCookie( $name, $options=[])
Unset a browser cookie.
Definition: WebResponse.php:260
MediaWiki\Config\ServiceOptions
A class for passing options to services.
Definition: ServiceOptions.php:27
MediaWiki\User\UserIdentity\isRegistered
isRegistered()
MediaWiki\Block\BlockManager\shouldTrackBlockWithCookie
shouldTrackBlockWithCookie(AbstractBlock $block, $isAnon)
Check if the block should be tracked with a cookie.
Definition: BlockManager.php:608
MediaWiki\Block\BlockManager\setBlockCookie
setBlockCookie(DatabaseBlock $block, WebResponse $response)
Set the 'BlockID' cookie to this block's ID and expiry time.
Definition: BlockManager.php:580
MediaWiki\Block\BlockManager\isLocallyBlockedProxy
isLocallyBlockedProxy( $ip)
Check if an IP address is in the local proxy list.
Definition: BlockManager.php:411
MediaWiki\Block\CompositeBlock
Multiple Block class.
Definition: CompositeBlock.php:36
MediaWiki\Block\BlockManager\getUniqueBlocks
getUniqueBlocks(array $blocks)
Given a list of blocks, return a list of unique blocks.
Definition: BlockManager.php:323
MediaWiki\Block\BlockManager\inDnsBlacklist
inDnsBlacklist( $ip, array $bases)
Whether the given IP is in a given DNS blacklist.
Definition: BlockManager.php:450
WebResponse\headersSent
headersSent()
Test if headers have been sent.
Definition: WebResponse.php:117
MediaWiki\Block\BlockManager\getIdFromCookieValue
getIdFromCookieValue( $cookieValue)
Get the stored ID from the 'BlockID' cookie.
Definition: BlockManager.php:645
MediaWiki\Block\DatabaseBlock\getId
getId( $wikiId=self::LOCAL)
Get the block ID.(since 1.38) ?int
Definition: DatabaseBlock.php:734
MediaWiki\Block\Block\TYPE_RANGE
const TYPE_RANGE
Definition: Block.php:46
MediaWiki\Block\AbstractBlock\getType
getType()
Get the type of target for this particular block.
Definition: AbstractBlock.php:316
MediaWiki\Block\DatabaseBlock\isExpired
isExpired()
Has the block expired?
Definition: DatabaseBlock.php:653
MediaWiki\Block\DatabaseBlock\getBlocksForIPList
static getBlocksForIPList(array $ipChain, $isAnon, $fromPrimary=false)
Get all blocks that match any IP from an array of IP addresses.
Definition: DatabaseBlock.php:903
MediaWiki\Block\BlockManager\getUserBlock
getUserBlock(UserIdentity $user, $request, $fromReplica, $disableIpBlockExemptChecking=false)
Get the blocks that apply to a user.
Definition: BlockManager.php:132
MediaWiki\Block\DatabaseBlock\isAutoblocking
isAutoblocking( $x=null)
Definition: DatabaseBlock.php:785
MediaWiki\Permissions\PermissionManager
A service class for checking permissions To obtain an instance, use MediaWikiServices::getInstance()-...
Definition: PermissionManager.php:52
MediaWiki\Block\BlockManager\getBlockFromCookieValue
getBlockFromCookieValue(UserIdentity $user, WebRequest $request)
Try to load a block from an ID given in a cookie value.
Definition: BlockManager.php:355
MediaWiki\Block\SystemBlock
System blocks are temporary blocks that are created on enforcement (e.g.
Definition: SystemBlock.php:35
MediaWiki\Block\BlockManager\$options
ServiceOptions $options
Definition: BlockManager.php:55
MediaWiki\Block\BlockManager\clearBlockCookie
static clearBlockCookie(WebResponse $response)
Unset the 'BlockID' cookie.
Definition: BlockManager.php:631
MediaWiki\Block\BlockManager\$permissionManager
PermissionManager $permissionManager
Definition: BlockManager.php:49
MediaWiki\Block\AbstractBlock\getExpiry
getExpiry()
Get the block expiry time.
Definition: AbstractBlock.php:358
MediaWiki\Block\Block\TYPE_AUTO
const TYPE_AUTO
Definition: Block.php:47
MediaWiki\Block\Block\TYPE_USER
const TYPE_USER
Definition: Block.php:44
WebRequest\getCookie
getCookie( $key, $prefix=null, $default=null)
Get a cookie from the $_COOKIE jar.
Definition: WebRequest.php:863
MediaWiki\Block\BlockManager\createGetBlockResult
createGetBlockResult(?string $ip, array $blocks)
Definition: BlockManager.php:190
WebRequest
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
Definition: WebRequest.php:43
MediaWiki\Block\BlockManager\getCookieValue
getCookieValue(DatabaseBlock $block)
Get the BlockID cookie's value for this block.
Definition: BlockManager.php:678
MediaWiki\Block\DatabaseBlock\newListFromTarget
static newListFromTarget( $specificTarget, $vagueTarget=null, $fromPrimary=false)
This is similar to DatabaseBlock::newFromTarget, but it returns all the relevant blocks.
Definition: DatabaseBlock.php:868
MediaWiki\Block\BlockManager\CONSTRUCTOR_OPTIONS
const CONSTRUCTOR_OPTIONS
Definition: BlockManager.php:60
Message
The Message class deals with fetching and processing of interface message into a variety of formats.
Definition: Message.php:139
MediaWiki\Block\BlockManager\__construct
__construct(ServiceOptions $options, PermissionManager $permissionManager, UserFactory $userFactory, LoggerInterface $logger, HookContainer $hookContainer)
Definition: BlockManager.php:85
MediaWiki\Block\BlockManager\$hookRunner
HookRunner $hookRunner
Definition: BlockManager.php:76
MediaWiki\Block\BlockManager\$userFactory
UserFactory $userFactory
Definition: BlockManager.php:52
MediaWiki\HookContainer\HookContainer
HookContainer class.
Definition: HookContainer.php:45
MediaWiki\Block\AbstractBlock
Definition: AbstractBlock.php:38
MediaWiki\HookContainer\HookRunner
This class provides an implementation of the core hook interfaces, forwarding hook calls to HookConta...
Definition: HookRunner.php:557
MediaWiki\Block\BlockManager\checkHost
checkHost( $hostname)
Wrapper for mocking in tests.
Definition: BlockManager.php:502
WebResponse
Allow programs to request this object from WebRequest::response() and handle all outputting (or lack ...
Definition: WebResponse.php:31
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:67
MediaWiki\User\UserFactory
Creates User objects.
Definition: UserFactory.php:41
MediaWiki\Block\Block\TYPE_IP
const TYPE_IP
Definition: Block.php:45
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\DatabaseBlock\newFromID
static newFromID( $id)
Load a block from the block id.
Definition: DatabaseBlock.php:138
MediaWiki\Block\BlockManager\getSystemIpBlocks
getSystemIpBlocks(string $ip, bool $isAnon)
Get any system blocks against the IP address.
Definition: BlockManager.php:250