MediaWiki REL1_34
MediaWiki\Block\BlockRestrictionStore Class Reference
Collaboration diagram for MediaWiki\Block\BlockRestrictionStore:

Public Member Functions

 __construct (ILoadBalancer $loadBalancer)
 
 delete (array $restrictions)
 Delete the restrictions.
 
 deleteByBlockId ( $blockId)
 Delete the restrictions by block ID.
 
 deleteByParentBlockId ( $parentBlockId)
 Delete the restrictions by parent block ID.
 
 equals (array $a, array $b)
 Checks if two arrays of Restrictions are effectively equal.
 
 insert (array $restrictions)
 Inserts the restrictions into the database.
 
 loadByBlockId ( $blockId, IDatabase $db=null)
 Retrieves the restrictions from the database by block id.
 
 setBlockId ( $blockId, array $restrictions)
 Set the blockId on a set of restrictions and return a new set.
 
 update (array $restrictions)
 Updates the list of restrictions.
 
 updateByParentBlockId ( $parentBlockId, array $restrictions)
 Updates the list of restrictions by parent id.
 

Private Member Functions

 restrictionsByBlockId (array $restrictions)
 Converts an array of restrictions to an associative array of restrictions where the keys are the block ids.
 
 restrictionsToRemove (array $existing, array $new)
 Get the restrictions that should be removed, which are existing restrictions that are not in the new list of restrictions.
 
 resultToRestrictions (IResultWrapper $result)
 Convert an Result Wrapper to an array of restrictions.
 
 rowToRestriction (stdClass $row)
 Convert a result row from the database into a restriction object.
 

Private Attributes

ILoadBalancer $loadBalancer
 
 $types
 Map of all of the restriction types.
 

Detailed Description

Definition at line 34 of file BlockRestrictionStore.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Block\BlockRestrictionStore::__construct ( ILoadBalancer  $loadBalancer)
Parameters
ILoadBalancer$loadBalancerload balancer for acquiring database connections

Definition at line 52 of file BlockRestrictionStore.php.

References MediaWiki\Block\BlockRestrictionStore\$loadBalancer.

Member Function Documentation

◆ delete()

MediaWiki\Block\BlockRestrictionStore::delete ( array  $restrictions)

Delete the restrictions.

Since
1.33
Parameters
Restriction[]$restrictions
Exceptions
MWException
Returns
bool

Definition at line 232 of file BlockRestrictionStore.php.

References $success, and DB_MASTER.

◆ deleteByBlockId()

MediaWiki\Block\BlockRestrictionStore::deleteByBlockId (   $blockId)

Delete the restrictions by block ID.

Since
1.33
Parameters
int | array$blockId
Exceptions
MWException
Returns
bool

Definition at line 262 of file BlockRestrictionStore.php.

References DB_MASTER.

◆ deleteByParentBlockId()

MediaWiki\Block\BlockRestrictionStore::deleteByParentBlockId (   $parentBlockId)

Delete the restrictions by parent block ID.

Since
1.33
Parameters
int | array$parentBlockId
Exceptions
MWException
Returns
bool

Definition at line 279 of file BlockRestrictionStore.php.

References DB_MASTER.

Referenced by MediaWiki\Block\BlockRestrictionStore\updateByParentBlockId().

◆ equals()

MediaWiki\Block\BlockRestrictionStore::equals ( array  $a,
array  $b 
)

Checks if two arrays of Restrictions are effectively equal.

This is a loose equality check as the restrictions do not have to contain the same block ids.

Since
1.33
Parameters
Restriction[]$a
Restriction[]$b
Returns
bool

Definition at line 301 of file BlockRestrictionStore.php.

References $filter.

◆ insert()

MediaWiki\Block\BlockRestrictionStore::insert ( array  $restrictions)

Inserts the restrictions into the database.

Since
1.33
Parameters
Restriction[]$restrictions
Returns
bool

Definition at line 90 of file BlockRestrictionStore.php.

References DB_MASTER.

Referenced by MediaWiki\Block\BlockRestrictionStore\update().

◆ loadByBlockId()

MediaWiki\Block\BlockRestrictionStore::loadByBlockId (   $blockId,
IDatabase  $db = null 
)

Retrieves the restrictions from the database by block id.

Since
1.33
Parameters
int | array$blockId
IDatabase | null$db
Returns
Restriction[]

Definition at line 64 of file BlockRestrictionStore.php.

References DB_REPLICA, and MediaWiki\Block\BlockRestrictionStore\resultToRestrictions().

◆ restrictionsByBlockId()

MediaWiki\Block\BlockRestrictionStore::restrictionsByBlockId ( array  $restrictions)
private

Converts an array of restrictions to an associative array of restrictions where the keys are the block ids.

Parameters
Restriction[]$restrictions
Returns
array

Definition at line 396 of file BlockRestrictionStore.php.

Referenced by MediaWiki\Block\BlockRestrictionStore\update().

◆ restrictionsToRemove()

MediaWiki\Block\BlockRestrictionStore::restrictionsToRemove ( array  $existing,
array  $new 
)
private

Get the restrictions that should be removed, which are existing restrictions that are not in the new list of restrictions.

Parameters
Restriction[]$existing
Restriction[]$new
Returns
array

Definition at line 373 of file BlockRestrictionStore.php.

Referenced by MediaWiki\Block\BlockRestrictionStore\update().

◆ resultToRestrictions()

MediaWiki\Block\BlockRestrictionStore::resultToRestrictions ( IResultWrapper  $result)
private

Convert an Result Wrapper to an array of restrictions.

Parameters
IResultWrapper$result
Returns
Restriction[]

Definition at line 421 of file BlockRestrictionStore.php.

References MediaWiki\Block\BlockRestrictionStore\rowToRestriction().

Referenced by MediaWiki\Block\BlockRestrictionStore\loadByBlockId(), and MediaWiki\Block\BlockRestrictionStore\update().

◆ rowToRestriction()

MediaWiki\Block\BlockRestrictionStore::rowToRestriction ( stdClass  $row)
private

Convert a result row from the database into a restriction object.

Parameters
stdClass$row
Returns
Restriction|null

Definition at line 442 of file BlockRestrictionStore.php.

Referenced by MediaWiki\Block\BlockRestrictionStore\resultToRestrictions().

◆ setBlockId()

MediaWiki\Block\BlockRestrictionStore::setBlockId (   $blockId,
array  $restrictions 
)

Set the blockId on a set of restrictions and return a new set.

Since
1.33
Parameters
int$blockId
Restriction[]$restrictions
Returns
Restriction[]

Definition at line 346 of file BlockRestrictionStore.php.

Referenced by MediaWiki\Block\BlockRestrictionStore\updateByParentBlockId().

◆ update()

MediaWiki\Block\BlockRestrictionStore::update ( array  $restrictions)

Updates the list of restrictions.

This method does not allow removing all of the restrictions. To do that, use ::deleteByBlockId().

Since
1.33
Parameters
Restriction[]$restrictions
Returns
bool

Definition at line 127 of file BlockRestrictionStore.php.

References $success, DB_MASTER, MediaWiki\Block\BlockRestrictionStore\insert(), MediaWiki\Block\BlockRestrictionStore\restrictionsByBlockId(), MediaWiki\Block\BlockRestrictionStore\restrictionsToRemove(), and MediaWiki\Block\BlockRestrictionStore\resultToRestrictions().

Referenced by MediaWiki\Block\BlockRestrictionStore\updateByParentBlockId().

◆ updateByParentBlockId()

MediaWiki\Block\BlockRestrictionStore::updateByParentBlockId (   $parentBlockId,
array  $restrictions 
)

Updates the list of restrictions by parent id.

Since
1.33
Parameters
int$parentBlockId
Restriction[]$restrictions
Returns
bool

Definition at line 192 of file BlockRestrictionStore.php.

References $success, DB_MASTER, MediaWiki\Block\BlockRestrictionStore\deleteByParentBlockId(), MediaWiki\Block\BlockRestrictionStore\setBlockId(), and MediaWiki\Block\BlockRestrictionStore\update().

Member Data Documentation

◆ $loadBalancer

ILoadBalancer MediaWiki\Block\BlockRestrictionStore::$loadBalancer
private

◆ $types

MediaWiki\Block\BlockRestrictionStore::$types
private
Initial value:
= [
PageRestriction::TYPE_ID => PageRestriction::class,
NamespaceRestriction::TYPE_ID => NamespaceRestriction::class,
]

Map of all of the restriction types.

Definition at line 39 of file BlockRestrictionStore.php.


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