MediaWiki REL1_33
|
A service class for checking permissions To obtain an instance, use MediaWikiServices::getInstance()->getPermissionManager(). More...
Public Member Functions | |
__construct (SpecialPageFactory $specialPageFactory, $whitelistRead, $whitelistReadRegexp, $emailConfirmToEdit, $blockDisablesLogin) | |
getPermissionErrors ( $action, User $user, LinkTarget $page, $rigor=self::RIGOR_SECURE, $ignoreErrors=[]) | |
Can $user perform $action on a page? | |
isBlockedFrom (User $user, LinkTarget $page, $fromReplica=false) | |
Check if user is blocked from editing a particular article. | |
userCan ( $action, User $user, LinkTarget $page, $rigor=self::RIGOR_SECURE) | |
Can $user perform $action on a page? | |
Private Member Functions | |
checkActionPermissions ( $action, User $user, $errors, $rigor, $short, LinkTarget $page) | |
Check action permissions not already checked in checkQuickPermissions. | |
checkCascadingSourcesRestrictions ( $action, User $user, $errors, $rigor, $short, LinkTarget $page) | |
Check restrictions on cascading pages. | |
checkPageRestrictions ( $action, User $user, $errors, $rigor, $short, LinkTarget $page) | |
Check against page_restrictions table requirements on this page. | |
checkPermissionHooks ( $action, User $user, $errors, $rigor, $short, LinkTarget $page) | |
Check various permission hooks. | |
checkQuickPermissions ( $action, User $user, $errors, $rigor, $short, LinkTarget $page) | |
Permissions checks that fail most often, and which are easiest to test. | |
checkReadPermissions ( $action, User $user, $errors, $rigor, $short, LinkTarget $page) | |
Check that the user is allowed to read this page. | |
checkSiteConfigPermissions ( $action, User $user, $errors, $rigor, $short, LinkTarget $page) | |
Check sitewide CSS/JSON/JS permissions. | |
checkSpecialsAndNSPermissions ( $action, User $user, $errors, $rigor, $short, LinkTarget $page) | |
Check permissions on special pages & namespaces. | |
checkUserBlock ( $action, User $user, $errors, $rigor, $short, LinkTarget $page) | |
Check that the user isn't blocked from editing. | |
checkUserConfigPermissions ( $action, User $user, $errors, $rigor, $short, LinkTarget $page) | |
Check CSS/JSON/JS sub-page permissions. | |
getPermissionErrorsInternal ( $action, User $user, LinkTarget $page, $rigor=self::RIGOR_SECURE, $short=false) | |
Can $user perform $action on a page? This is an internal function, with multiple levels of checks depending on performance needs; see $rigor below. | |
isSameSpecialPage ( $name, LinkTarget $page) | |
Returns true if this title resolves to the named special page. | |
missingPermissionError ( $action, $short) | |
Get a description array when the user doesn't have the right to perform $action (i.e. | |
resultToError ( $errors, $result) | |
Add the resulting error code to the errors array. | |
Private Attributes | |
bool | $blockDisablesLogin |
If set to true, blocked users will no longer be allowed to log in. | |
bool | $emailConfirmToEdit |
Require users to confirm email address before they can edit. | |
SpecialPageFactory | $specialPageFactory |
string[] | $whitelistRead |
List of pages names anonymous user may see. | |
string[] | $whitelistReadRegexp |
Whitelists publicly readable titles with regular expressions. | |
A service class for checking permissions To obtain an instance, use MediaWikiServices::getInstance()->getPermissionManager().
Definition at line 43 of file PermissionManager.php.
MediaWiki\Permissions\PermissionManager::__construct | ( | SpecialPageFactory | $specialPageFactory, |
$whitelistRead, | |||
$whitelistReadRegexp, | |||
$emailConfirmToEdit, | |||
$blockDisablesLogin | |||
) |
SpecialPageFactory | $specialPageFactory | |
string[] | $whitelistRead | |
string[] | $whitelistReadRegexp | |
bool | $emailConfirmToEdit | |
bool | $blockDisablesLogin |
Definition at line 76 of file PermissionManager.php.
References MediaWiki\Permissions\PermissionManager\$blockDisablesLogin, MediaWiki\Permissions\PermissionManager\$emailConfirmToEdit, MediaWiki\Permissions\PermissionManager\$specialPageFactory, MediaWiki\Permissions\PermissionManager\$whitelistRead, and MediaWiki\Permissions\PermissionManager\$whitelistReadRegexp.
|
private |
Check action permissions not already checked in checkQuickPermissions.
string | $action | The action to check |
User | $user | User to check |
array | $errors | List of current errors |
string | $rigor | One of PermissionManager::RIGOR_ constants
|
bool | $short | Short circuit on first error |
LinkTarget | $page |
Exception |
Definition at line 786 of file PermissionManager.php.
References $user, $wgDeleteRevisionsLimit, $wgLang, MediaWiki\Permissions\PermissionManager\checkCascadingSourcesRestrictions(), MediaWiki\Permissions\PermissionManager\checkPageRestrictions(), MediaWiki\Linker\LinkTarget\getNamespace(), MediaWiki\Permissions\PermissionManager\getPermissionErrorsInternal(), MediaWiki\Permissions\PermissionManager\userCan(), and User\whoIs().
|
private |
Check restrictions on cascading pages.
string | $action | The action to check |
User | $user | User to check |
array | $errors | List of current errors |
string | $rigor | One of PermissionManager::RIGOR_ constants
|
bool | $short | Short circuit on first error |
LinkTarget | $page |
Definition at line 724 of file PermissionManager.php.
References $user, as, and list.
Referenced by MediaWiki\Permissions\PermissionManager\checkActionPermissions().
|
private |
Check against page_restrictions table requirements on this page.
The user must possess all required rights for this action.
string | $action | The action to check |
User | $user | User to check |
array | $errors | List of current errors |
string | $rigor | One of PermissionManager::RIGOR_ constants
|
bool | $short | Short circuit on first error |
LinkTarget | $page |
Definition at line 676 of file PermissionManager.php.
Referenced by MediaWiki\Permissions\PermissionManager\checkActionPermissions().
|
private |
Check various permission hooks.
string | $action | The action to check |
User | $user | User to check |
array | $errors | List of current errors |
string | $rigor | One of PermissionManager::RIGOR_ constants
|
bool | $short | Short circuit on first error |
LinkTarget | $page |
FatalError | |
MWException |
Definition at line 286 of file PermissionManager.php.
References $user, and MediaWiki\Permissions\PermissionManager\resultToError().
|
private |
Permissions checks that fail most often, and which are easiest to test.
string | $action | The action to check |
User | $user | User to check |
array | $errors | List of current errors |
string | $rigor | One of PermissionManager::RIGOR_ constants
|
bool | $short | Short circuit on first error |
LinkTarget | $page |
FatalError | |
MWException |
Definition at line 583 of file PermissionManager.php.
References $user, false, MediaWiki\Linker\LinkTarget\getNamespace(), MediaWiki\Linker\LinkTarget\getText(), User\groupHasPermission(), MediaWiki\Permissions\PermissionManager\missingPermissionError(), NS_CATEGORY, NS_FILE, and NS_USER.
|
private |
Check that the user is allowed to read this page.
string | $action | The action to check |
User | $user | User to check |
array | $errors | List of current errors |
string | $rigor | One of PermissionManager::RIGOR_ constants
|
bool | $short | Short circuit on first error |
LinkTarget | $page |
FatalError | |
MWException |
Definition at line 363 of file PermissionManager.php.
References $name, $user, as, MediaWiki\Linker\LinkTarget\getDBkey(), MediaWiki\Linker\LinkTarget\getNamespace(), SpecialPage\getTitleFor(), User\isEveryoneAllowed(), MediaWiki\Permissions\PermissionManager\isSameSpecialPage(), list, MediaWiki\Permissions\PermissionManager\missingPermissionError(), and NS_MAIN.
|
private |
Check sitewide CSS/JSON/JS permissions.
string | $action | The action to check |
User | $user | User to check |
array | $errors | List of current errors |
string | $rigor | One of PermissionManager::RIGOR_ constants
|
bool | $short | Short circuit on first error |
LinkTarget | $page |
Definition at line 923 of file PermissionManager.php.
References $user, and wfMessage().
|
private |
Check permissions on special pages & namespaces.
string | $action | The action to check |
User | $user | User to check |
array | $errors | List of current errors |
string | $rigor | One of PermissionManager::RIGOR_ constants
|
bool | $short | Short circuit on first error |
LinkTarget | $page |
Definition at line 879 of file PermissionManager.php.
References $user, MediaWiki\Linker\LinkTarget\getNamespace(), NS_MAIN, NS_MEDIAWIKI, NS_SPECIAL, and wfMessage().
|
private |
Check that the user isn't blocked from editing.
string | $action | The action to check |
User | $user | User to check |
array | $errors | List of current errors |
string | $rigor | One of PermissionManager::RIGOR_ constants
|
bool | $short | Short circuit on first error |
LinkTarget | $page |
MWException |
Definition at line 496 of file PermissionManager.php.
References $user, Action\exists(), Action\factory(), WikiPage\factory(), false, RequestContext\getMain(), and MediaWiki\Permissions\PermissionManager\isBlockedFrom().
|
private |
Check CSS/JSON/JS sub-page permissions.
string | $action | The action to check |
User | $user | User to check |
array | $errors | List of current errors |
string | $rigor | One of PermissionManager::RIGOR_ constants
|
bool | $short | Short circuit on first error |
LinkTarget | $page |
Definition at line 983 of file PermissionManager.php.
References $user, and MediaWiki\Linker\LinkTarget\getText().
MediaWiki\Permissions\PermissionManager::getPermissionErrors | ( | $action, | |
User | $user, | ||
LinkTarget | $page, | ||
$rigor = self::RIGOR_SECURE , |
|||
$ignoreErrors = [] |
|||
) |
Can $user perform $action on a page?
string | $action | Action that permission needs to be checked for |
User | $user | User to check |
LinkTarget | $page | |
string | $rigor | One of PermissionManager::RIGOR_ constants
|
array | $ignoreErrors | Array of Strings Set this to a list of message keys whose corresponding errors may be ignored. |
Exception |
Definition at line 132 of file PermissionManager.php.
References $user, as, and MediaWiki\Permissions\PermissionManager\getPermissionErrorsInternal().
|
private |
Can $user perform $action on a page? This is an internal function, with multiple levels of checks depending on performance needs; see $rigor below.
It does not check wfReadOnly().
string | $action | Action that permission needs to be checked for |
User | $user | User to check |
LinkTarget | $page | |
string | $rigor | One of PermissionManager::RIGOR_ constants
|
bool | $short | Set this to true to stop after the first permission error. |
Exception |
Definition at line 211 of file PermissionManager.php.
Referenced by MediaWiki\Permissions\PermissionManager\checkActionPermissions(), MediaWiki\Permissions\PermissionManager\getPermissionErrors(), and MediaWiki\Permissions\PermissionManager\userCan().
MediaWiki\Permissions\PermissionManager::isBlockedFrom | ( | User | $user, |
LinkTarget | $page, | ||
$fromReplica = false |
|||
) |
Check if user is blocked from editing a particular article.
User | $user | |
LinkTarget | $page | Title to check |
bool | $fromReplica | Whether to check the replica DB instead of the master |
FatalError | |
MWException |
Definition at line 167 of file PermissionManager.php.
References $user.
Referenced by MediaWiki\Permissions\PermissionManager\checkUserBlock().
|
private |
Returns true if this title resolves to the named special page.
string | $name | The special page name |
LinkTarget | $page |
Definition at line 468 of file PermissionManager.php.
References $name, MediaWiki\Linker\LinkTarget\getDBkey(), MediaWiki\Linker\LinkTarget\getNamespace(), list, and NS_SPECIAL.
Referenced by MediaWiki\Permissions\PermissionManager\checkReadPermissions().
|
private |
Get a description array when the user doesn't have the right to perform $action (i.e.
when User::isAllowed() returns false)
string | $action | The action to check |
bool | $short | Short circuit on first error |
Definition at line 449 of file PermissionManager.php.
References User\newFatalPermissionDeniedStatus().
Referenced by MediaWiki\Permissions\PermissionManager\checkQuickPermissions(), and MediaWiki\Permissions\PermissionManager\checkReadPermissions().
|
private |
Add the resulting error code to the errors array.
array | $errors | List of current errors |
array | $result | Result of errors |
Definition at line 325 of file PermissionManager.php.
Referenced by MediaWiki\Permissions\PermissionManager\checkPermissionHooks().
MediaWiki\Permissions\PermissionManager::userCan | ( | $action, | |
User | $user, | ||
LinkTarget | $page, | ||
$rigor = self::RIGOR_SECURE |
|||
) |
Can $user perform $action on a page?
The method is intended to replace Title::userCan() The $user parameter need to be superseded by UserIdentity value in future The $title parameter need to be superseded by PageIdentity value in future
string | $action | |
User | $user | |
LinkTarget | $page | |
string | $rigor | One of PermissionManager::RIGOR_ constants
|
Exception |
Definition at line 110 of file PermissionManager.php.
References $user, and MediaWiki\Permissions\PermissionManager\getPermissionErrorsInternal().
Referenced by MediaWiki\Permissions\PermissionManager\checkActionPermissions().
|
private |
If set to true, blocked users will no longer be allowed to log in.
Definition at line 67 of file PermissionManager.php.
Referenced by MediaWiki\Permissions\PermissionManager\__construct().
|
private |
Require users to confirm email address before they can edit.
Definition at line 64 of file PermissionManager.php.
Referenced by MediaWiki\Permissions\PermissionManager\__construct().
|
private |
Definition at line 55 of file PermissionManager.php.
Referenced by MediaWiki\Permissions\PermissionManager\__construct().
|
private |
List of pages names anonymous user may see.
Definition at line 58 of file PermissionManager.php.
Referenced by MediaWiki\Permissions\PermissionManager\__construct().
|
private |
Whitelists publicly readable titles with regular expressions.
Definition at line 61 of file PermissionManager.php.
Referenced by MediaWiki\Permissions\PermissionManager\__construct().