MediaWiki master
MediaWiki\User\UserRequirementsConditionChecker Class Reference

Public Member Functions

 __construct (private readonly ServiceOptions $options, HookContainer $hookContainer, private readonly UserFactory $userFactory, private readonly IContextSource $context, private readonly UserRequirementsConditionValidator $userRequirementsConditionValidator, private readonly array UserRequirementsConditionEvaluatorBase[] $evaluators=[],)
 
 extractConditions ( $cond)
 Goes through a condition passed as the input and extracts all simple conditions that are used within it.
 
 extractPrivateConditions ( $cond)
 Goes through a condition passed as the input and extracts all private conditions that are used within it.
 
 recursivelyCheckCondition ( $cond, UserIdentity $user, bool $usePrivateConditions=true)
 Recursively check a condition.
 

Public Attributes

const CONSTRUCTOR_OPTIONS
 
const VALID_OPS = [ '&', '|', '^', '!' ]
 Logical operators recognized in $wgAutopromote.
 

Protected Member Functions

 checkCondition (array $cond, UserIdentity $user)
 As recursivelyCheckCondition, but not recursive.
 

Detailed Description

Since
1.45

Definition at line 21 of file UserRequirementsConditionChecker.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\User\UserRequirementsConditionChecker::__construct ( private readonly ServiceOptions $options,
HookContainer $hookContainer,
private readonly UserFactory $userFactory,
private readonly IContextSource $context,
private readonly UserRequirementsConditionValidator $userRequirementsConditionValidator,
private readonly array UserRequirementsConditionEvaluatorBase[] $evaluators = [] )

Definition at line 37 of file UserRequirementsConditionChecker.php.

Member Function Documentation

◆ checkCondition()

MediaWiki\User\UserRequirementsConditionChecker::checkCondition ( array $cond,
UserIdentity $user )
protected

As recursivelyCheckCondition, but not recursive.

The only valid conditions are those whose first element is one of APCOND_* defined in Defines.php. Other types will throw an exception if no extension evaluates them.

Parameters
array$condA condition, which must not contain other conditions. This array must contain at least one item, which is the condition type.
UserIdentity$userThe user to check the condition against
Returns
?bool Whether the condition is true for the user. Null if it's a private condition and we're not supposed to evaluate these.
Exceptions
InvalidArgumentExceptionif autopromote condition was not recognized.
LogicExceptionif APCOND_BLOCKED is checked again before returning a result.

Definition at line 63 of file UserRequirementsConditionChecker.php.

◆ extractConditions()

MediaWiki\User\UserRequirementsConditionChecker::extractConditions ( $cond)

Goes through a condition passed as the input and extracts all simple conditions that are used within it.

Simple condition is any condition that is not a logical operator, for example APCOND_EDITCOUNT is a simple condition.

Parameters
mixed$condA condition, possibly containing other conditions.
Returns
list<mixed> A list of unique private conditions present in $cond
Since
1.46

Definition at line 246 of file UserRequirementsConditionChecker.php.

◆ extractPrivateConditions()

MediaWiki\User\UserRequirementsConditionChecker::extractPrivateConditions ( $cond)

Goes through a condition passed as the input and extracts all private conditions that are used within it.

Parameters
mixed$condA condition, possibly containing other conditions.
Returns
list<mixed> A list of unique private conditions present in $cond
Since
1.46

Definition at line 230 of file UserRequirementsConditionChecker.php.

◆ recursivelyCheckCondition()

MediaWiki\User\UserRequirementsConditionChecker::recursivelyCheckCondition ( $cond,
UserIdentity $user,
bool $usePrivateConditions = true )

Recursively check a condition.

Conditions are in the form [ '&' or '|' or '^' or '!', cond1, cond2, ... ] where cond1, cond2, ... are themselves conditions; OR APCOND_EMAILCONFIRMED, OR [ APCOND_EMAILCONFIRMED ], OR [ APCOND_EDITCOUNT, number of edits ], OR [ APCOND_AGE, seconds since registration ], OR similar constructs defined by extensions. This function evaluates the former type recursively, and passes off to checkCondition for evaluation of the latter type.

If you change the logic of this method, please update ApiQuerySiteinfo::appendAutoPromote(), as it depends on this method.

If the passed condition is invalid, false is returned without evaluating it.

Parameters
mixed$condA condition, possibly containing other conditions
UserIdentity$userThe user to check the conditions against
bool$usePrivateConditionsWhether to evaluate private conditions
Returns
?bool Whether the condition is true; will be null if the condition value depends on any of the unevaluated private conditions. Non-null value means that the skipped conditions have no effect on the result. Null can be returned only if $usePrivateConditions is false.

Definition at line 125 of file UserRequirementsConditionChecker.php.

Member Data Documentation

◆ CONSTRUCTOR_OPTIONS

const MediaWiki\User\UserRequirementsConditionChecker::CONSTRUCTOR_OPTIONS
Initial value:
= [
]
const UserRequirementsPrivateConditions
Name constant for the UserRequirementsPrivateConditions setting, for use with Config::get()
Access: internal
For use by UserRequirementsConditionCheckerFactory

Definition at line 31 of file UserRequirementsConditionChecker.php.

Referenced by MediaWiki\User\UserRequirementsConditionCheckerFactory\__construct().

◆ VALID_OPS

const MediaWiki\User\UserRequirementsConditionChecker::VALID_OPS = [ '&', '|', '^', '!' ]

Logical operators recognized in $wgAutopromote.

Since
1.45

Definition at line 28 of file UserRequirementsConditionChecker.php.


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