MediaWiki master
MediaWiki\Block\BlockUtils Class Reference

Backend class for blocking utils. More...

Public Member Functions

 __construct (ServiceOptions $options, UserIdentityLookup $userIdentityLookup, UserNameUtils $userNameUtils, $wikiId=Block::LOCAL)
 
 parseBlockTarget ( $target)
 From string specification or UserIdentity, get the block target and the type of target.
 
 parseBlockTargetRow ( $row)
 From a row which must contain bt_auto, bt_user, bt_address and bl_id, and optionally bt_user_text, determine the block target and type.
 
 validateTarget ( $value)
 Validate block target.
 

Public Attributes

const CONSTRUCTOR_OPTIONS
 

Detailed Description

Backend class for blocking utils.

This service should contain any methods that are useful to more than one blocking-related class and don't fit any other service.

For now, this includes only

  • block target parsing
  • block target validation
  • parsing the target and type of a block in the database
Since
1.36

Definition at line 47 of file BlockUtils.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Block\BlockUtils::__construct ( ServiceOptions $options,
UserIdentityLookup $userIdentityLookup,
UserNameUtils $userNameUtils,
$wikiId = Block::LOCAL )

Member Function Documentation

◆ parseBlockTarget()

MediaWiki\Block\BlockUtils::parseBlockTarget ( $target)

From string specification or UserIdentity, get the block target and the type of target.

Note that, except for null, it is always safe to treat the target as a string; for UserIdentityValue objects this will return UserIdentityValue::__toString() which in turn gives UserIdentityValue::getName().

If the type is not null, it will be an AbstractBlock::TYPE_ constant.

Since 1.42, it is no longer safe to pass a value from the database field ipb_address/bt_address to this method, since the username is normalized. Use parseBlockTargetRow() instead. (T346683)

Parameters
string | UserIdentity | null$target
Returns
array [ UserIdentity|String|null, int|null ]

Definition at line 93 of file BlockUtils.php.

References MediaWiki\Block\Block\TYPE_IP, and MediaWiki\Block\Block\TYPE_USER.

Referenced by MediaWiki\Block\BlockPermissionChecker\__construct().

◆ parseBlockTargetRow()

MediaWiki\Block\BlockUtils::parseBlockTargetRow ( $row)

From a row which must contain bt_auto, bt_user, bt_address and bl_id, and optionally bt_user_text, determine the block target and type.

Since
1.42
Parameters
\\stdClass$row
Returns
array [ UserIdentity|String|null, int|null ]

Definition at line 153 of file BlockUtils.php.

References MediaWiki\Block\Block\TYPE_AUTO, MediaWiki\Block\Block\TYPE_IP, MediaWiki\Block\Block\TYPE_RANGE, and MediaWiki\Block\Block\TYPE_USER.

◆ validateTarget()

MediaWiki\Block\BlockUtils::validateTarget ( $value)

Validate block target.

Parameters
string | UserIdentity$value
Returns
Status

Definition at line 185 of file BlockUtils.php.

Member Data Documentation

◆ CONSTRUCTOR_OPTIONS

const MediaWiki\Block\BlockUtils::CONSTRUCTOR_OPTIONS
Initial value:
= [
]
const BlockCIDRLimit
Name constant for the BlockCIDRLimit setting, for use with Config::get()
Access: internal
Only for use by ServiceWiring

Definition at line 58 of file BlockUtils.php.


The documentation for this class was generated from the following file: