MediaWiki master
MediaWiki\User\UserRequirementsConditionChecker Class Reference

Public Member Functions

 __construct (private readonly ServiceOptions $options, private readonly GroupPermissionsLookup $groupPermissionsLookup, HookContainer $hookContainer, private readonly LoggerInterface $logger, private readonly UserEditTracker $userEditTracker, private readonly UserRegistrationLookup $userRegistrationLookup, private readonly UserFactory $userFactory, private readonly IContextSource $context, private readonly UserGroupManager $userGroupManager, private readonly string|false $wikiId=UserIdentity::LOCAL,)
 
 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
Stability: stable
to extend Since 1.46

Definition at line 29 of file UserRequirementsConditionChecker.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\User\UserRequirementsConditionChecker::__construct ( private readonly ServiceOptions $options,
private readonly GroupPermissionsLookup $groupPermissionsLookup,
HookContainer $hookContainer,
private readonly LoggerInterface $logger,
private readonly UserEditTracker $userEditTracker,
private readonly UserRegistrationLookup $userRegistrationLookup,
private readonly UserFactory $userFactory,
private readonly IContextSource $context,
private readonly UserGroupManager $userGroupManager,
private readonly string|false $wikiId = UserIdentity::LOCAL )

Definition at line 55 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.
Stability: stable
to override Since 1.46

Definition at line 85 of file UserRequirementsConditionChecker.php.

References APCOND_AGE, APCOND_AGE_FROM_EDIT, APCOND_BLOCKED, APCOND_EDITCOUNT, APCOND_EMAILCONFIRMED, APCOND_INGROUPS, APCOND_IPINRANGE, APCOND_ISBOT, APCOND_ISIP, MediaWiki\MainConfigNames\AutoConfirmAge, MediaWiki\MainConfigNames\AutoConfirmCount, MediaWiki\MainConfigNames\EmailAuthentication, and wfTimestampOrNull().

◆ 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

Definition at line 323 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.

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 217 of file UserRequirementsConditionChecker.php.

References MediaWiki\MainConfigNames\UserRequirementsPrivateConditions.

Member Data Documentation

◆ CONSTRUCTOR_OPTIONS

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

Definition at line 39 of file UserRequirementsConditionChecker.php.

◆ VALID_OPS

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

Logical operators recognized in $wgAutopromote.

Since
1.45

Definition at line 36 of file UserRequirementsConditionChecker.php.


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