MediaWiki master
MediaWiki\Permissions\RestrictionStore Class Reference

Public Member Functions

 __construct (ServiceOptions $options, WANObjectCache $wanCache, ILoadBalancer $loadBalancer, LinkCache $linkCache, LinksMigration $linksMigration, CommentStore $commentStore, HookContainer $hookContainer, PageStore $pageStore)
 
 areCascadeProtectionSourcesLoaded (PageIdentity $page)
 Determines whether cascading protection sources have already been loaded from the database.
 
 areRestrictionsCascading (PageIdentity $page)
 Checks if restrictions are cascading for the current page.
 
 areRestrictionsLoaded (PageIdentity $page)
 
 deleteCreateProtection (PageIdentity $page)
 Remove any title creation protection due to page existing.
 
 flushRestrictions (PageIdentity $page)
 Flush the protection cache in this object and force reload from the database.
 
 getAllRestrictions (PageIdentity $page)
 Returns the restricted actions and their restrictions for the specified page.
 
 getCascadeProtectionSources (PageIdentity $page)
 Cascading protection: Get the source of any cascading restrictions on this page.
 
 getCreateProtection (PageIdentity $page)
 Is this title subject to protection against creation?
 
 getRestrictionExpiry (PageIdentity $page, string $action)
 Get the expiry time for the restriction against a given action.
 
 getRestrictions (PageIdentity $page, string $action)
 Returns list of restrictions for specified page.
 
 isCascadeProtected (PageIdentity $page)
 Cascading protection: Return true if cascading restrictions apply to this page, false if not.
 
 isProtected (PageIdentity $page, string $action='')
 Does the title correspond to a protected article?
 
 isSemiProtected (PageIdentity $page, string $action='edit')
 Is this page "semi-protected" - the only protection levels are listed in $wgSemiprotectedRestrictionLevels?
 
 listAllRestrictionTypes (bool $exists=true)
 Get a filtered list of all restriction types supported by this wiki.
 
 listApplicableRestrictionTypes (PageIdentity $page)
 Returns restriction types for the current page.
 
 loadRestrictions (PageIdentity $page, int $flags=IDBAccessObject::READ_NORMAL)
 Load restrictions from page.page_restrictions and the page_restrictions table.
 
 loadRestrictionsFromRows (PageIdentity $page, array $rows)
 Compiles list of active page restrictions for this existing page.
 

Public Attributes

const CONSTRUCTOR_OPTIONS
 

Detailed Description

Since
1.37

Definition at line 29 of file RestrictionStore.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Permissions\RestrictionStore::__construct ( ServiceOptions $options,
WANObjectCache $wanCache,
ILoadBalancer $loadBalancer,
LinkCache $linkCache,
LinksMigration $linksMigration,
CommentStore $commentStore,
HookContainer $hookContainer,
PageStore $pageStore )

Member Function Documentation

◆ areCascadeProtectionSourcesLoaded()

MediaWiki\Permissions\RestrictionStore::areCascadeProtectionSourcesLoaded ( PageIdentity $page)

Determines whether cascading protection sources have already been loaded from the database.

Parameters
PageIdentity$pageMust be local
Returns
bool

Definition at line 638 of file RestrictionStore.php.

◆ areRestrictionsCascading()

MediaWiki\Permissions\RestrictionStore::areRestrictionsCascading ( PageIdentity $page)

Checks if restrictions are cascading for the current page.

Parameters
PageIdentity$pageMust be local
Returns
bool

Definition at line 650 of file RestrictionStore.php.

◆ areRestrictionsLoaded()

MediaWiki\Permissions\RestrictionStore::areRestrictionsLoaded ( PageIdentity $page)
Parameters
PageIdentity$pageMust be local
Returns
bool Whether or not the page's restrictions have already been loaded from the database

Definition at line 626 of file RestrictionStore.php.

◆ deleteCreateProtection()

MediaWiki\Permissions\RestrictionStore::deleteCreateProtection ( PageIdentity $page)

Remove any title creation protection due to page existing.

Parameters
PageIdentity$pageMust be local
Access: internal
Only to be called by WikiPage::onArticleCreate.

Definition at line 180 of file RestrictionStore.php.

◆ flushRestrictions()

MediaWiki\Permissions\RestrictionStore::flushRestrictions ( PageIdentity $page)

Flush the protection cache in this object and force reload from the database.

This is used when updating protection from WikiPage::doUpdateRestrictions().

Parameters
PageIdentity$pageMust be local
Access: internal

Definition at line 666 of file RestrictionStore.php.

◆ getAllRestrictions()

MediaWiki\Permissions\RestrictionStore::getAllRestrictions ( PageIdentity $page)

Returns the restricted actions and their restrictions for the specified page.

Parameters
PageIdentity$pageMust be local
Returns
string[][] Keys are actions, values are arrays as returned by RestrictionStore::getRestrictions(). Empty if no restrictions are in place.

Definition at line 118 of file RestrictionStore.php.

◆ getCascadeProtectionSources()

MediaWiki\Permissions\RestrictionStore::getCascadeProtectionSources ( PageIdentity $page)

Cascading protection: Get the source of any cascading restrictions on this page.

Parameters
PageIdentity$pageMust be local
Returns
array[] Two elements: First is an array of PageIdentity objects of the pages from which cascading restrictions have come, which may be empty. Second is an array like that returned by getAllRestrictions().

Definition at line 527 of file RestrictionStore.php.

◆ getCreateProtection()

MediaWiki\Permissions\RestrictionStore::getCreateProtection ( PageIdentity $page)

Is this title subject to protection against creation?

Parameters
PageIdentity$pageMust be local
Returns
?array Null if no restrictions. Otherwise an array with the following keys:
  • user: user id
  • expiry: 14-digit timestamp or 'infinity'
  • permission: string (pt_create_perm)
  • reason: string
Access: internal
Only to be called by Title::getTitleProtection. When that is discontinued, this will be too, in favor of getRestrictions( $page, 'create' ). If someone wants to know who protected it or the reason, there should be a method that exposes that for all restriction types.

Definition at line 158 of file RestrictionStore.php.

◆ getRestrictionExpiry()

MediaWiki\Permissions\RestrictionStore::getRestrictionExpiry ( PageIdentity $page,
string $action )

Get the expiry time for the restriction against a given action.

Parameters
PageIdentity$pageMust be local
string$action
Returns
?string 14-char timestamp, or 'infinity' if the page is protected forever or not protected at all, or null if the action is not recognized.

Definition at line 135 of file RestrictionStore.php.

◆ getRestrictions()

MediaWiki\Permissions\RestrictionStore::getRestrictions ( PageIdentity $page,
string $action )

Returns list of restrictions for specified page.

Parameters
PageIdentity$pageMust be local
string$actionAction that restrictions need to be checked for
Returns
string[] Restriction levels needed to take the action. All levels are required. Note that restriction levels are normally user rights, but 'sysop' and 'autoconfirmed' are also allowed for backwards compatibility. These should be mapped to 'editprotected' and 'editsemiprotected' respectively. Returns an empty array if there are no restrictions set for this action (including for unrecognized actions).

Definition at line 95 of file RestrictionStore.php.

◆ isCascadeProtected()

MediaWiki\Permissions\RestrictionStore::isCascadeProtected ( PageIdentity $page)

Cascading protection: Return true if cascading restrictions apply to this page, false if not.

Parameters
PageIdentity$pageMust be local
Returns
bool If the page is subject to cascading restrictions.

Definition at line 266 of file RestrictionStore.php.

◆ isProtected()

MediaWiki\Permissions\RestrictionStore::isProtected ( PageIdentity $page,
string $action = '' )

Does the title correspond to a protected article?

Parameters
PageIdentity$pageMust be local
string$actionThe action the page is protected from, by default checks all actions.
Returns
bool

Definition at line 227 of file RestrictionStore.php.

◆ isSemiProtected()

MediaWiki\Permissions\RestrictionStore::isSemiProtected ( PageIdentity $page,
string $action = 'edit' )

Is this page "semi-protected" - the only protection levels are listed in $wgSemiprotectedRestrictionLevels?

Parameters
PageIdentity$pageMust be local
string$actionAction to check (default: edit)
Returns
bool

Definition at line 199 of file RestrictionStore.php.

◆ listAllRestrictionTypes()

MediaWiki\Permissions\RestrictionStore::listAllRestrictionTypes ( bool $exists = true)

Get a filtered list of all restriction types supported by this wiki.

Parameters
bool$existsTrue to get all restriction types that apply to titles that do exist, false for all restriction types that apply to titles that do not exist
Returns
string[]

Definition at line 307 of file RestrictionStore.php.

◆ listApplicableRestrictionTypes()

MediaWiki\Permissions\RestrictionStore::listApplicableRestrictionTypes ( PageIdentity $page)

Returns restriction types for the current page.

Parameters
PageIdentity$pageMust be local
Returns
string[] Applicable restriction types

Definition at line 278 of file RestrictionStore.php.

◆ loadRestrictions()

MediaWiki\Permissions\RestrictionStore::loadRestrictions ( PageIdentity $page,
int $flags = IDBAccessObject::READ_NORMAL )

Load restrictions from page.page_restrictions and the page_restrictions table.

Parameters
PageIdentity$pageMust be local
int$flagsIDBAccessObject::READ_XXX constants (e.g., READ_LATEST to read from primary DB)
Access: internal
Public for use in WikiPage only

Definition at line 326 of file RestrictionStore.php.

◆ loadRestrictionsFromRows()

MediaWiki\Permissions\RestrictionStore::loadRestrictionsFromRows ( PageIdentity $page,
array $rows )

Compiles list of active page restrictions for this existing page.

Public for usage by LiquidThreads.

Parameters
PageIdentity$pageMust be local
stdClass[]$rowsArray of db result objects

Definition at line 422 of file RestrictionStore.php.

Member Data Documentation

◆ CONSTRUCTOR_OPTIONS

const MediaWiki\Permissions\RestrictionStore::CONSTRUCTOR_OPTIONS
Initial value:
= [
]
const NamespaceProtection
Name constant for the NamespaceProtection setting, for use with Config::get()
const RestrictionTypes
Name constant for the RestrictionTypes setting, for use with Config::get()
const SemiprotectedRestrictionLevels
Name constant for the SemiprotectedRestrictionLevels setting, for use with Config::get()
const RestrictionLevels
Name constant for the RestrictionLevels setting, for use with Config::get()
Access: internal

Definition at line 32 of file RestrictionStore.php.


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