MediaWiki master
|
Provides rate limiting for a set of actions based on several counter buckets. More...
Public Member Functions | |
__construct (ServiceOptions $options, WRStatsFactory $wrstatsFactory, ?CentralIdLookup $centralIdLookup, UserFactory $userFactory, UserGroupManager $userGroupManager, HookContainer $hookContainer) | |
isExempt (RateLimitSubject $subject) | |
Is this user exempt from rate limiting? | |
isLimitable ( $action) | |
Checks whether the given action may be limited. | |
limit (RateLimitSubject $subject, string $action, int $incrBy=1) | |
Implements simple rate limits: enforce maximum actions per time period to put a brake on flooding. | |
setStats (StatsdDataFactoryInterface $stats) | |
Public Attributes | |
const | CONSTRUCTOR_OPTIONS |
Provides rate limiting for a set of actions based on several counter buckets.
Definition at line 44 of file RateLimiter.php.
MediaWiki\Permissions\RateLimiter::__construct | ( | ServiceOptions | $options, |
WRStatsFactory | $wrstatsFactory, | ||
?CentralIdLookup | $centralIdLookup, | ||
UserFactory | $userFactory, | ||
UserGroupManager | $userGroupManager, | ||
HookContainer | $hookContainer ) |
Definition at line 86 of file RateLimiter.php.
References MediaWiki\Config\ServiceOptions\assertRequiredOptions(), and MediaWiki\MainConfigNames\RateLimits.
MediaWiki\Permissions\RateLimiter::isExempt | ( | RateLimitSubject | $subject | ) |
Is this user exempt from rate limiting?
RateLimitSubject | $subject | The subject of the rate limit, representing the client performing the action. |
Definition at line 125 of file RateLimiter.php.
References MediaWiki\Permissions\RateLimitSubject\getIP(), MediaWiki\Permissions\RateLimitSubject\is(), and MediaWiki\MainConfigNames\RateLimitsExcludedIPs.
Referenced by MediaWiki\Permissions\RateLimiter\limit().
MediaWiki\Permissions\RateLimiter::isLimitable | ( | $action | ) |
Checks whether the given action may be limited.
Can be used for optimization, to avoid calling limit() if we can know in advance that no limit will apply.
string | $action |
Definition at line 148 of file RateLimiter.php.
MediaWiki\Permissions\RateLimiter::limit | ( | RateLimitSubject | $subject, |
string | $action, | ||
int | $incrBy = 1 ) |
Implements simple rate limits: enforce maximum actions per time period to put a brake on flooding.
RateLimitSubject | $subject | The subject of the rate limit, representing the client performing the action. |
string | $action | Action to enforce |
int | $incrBy | Positive amount to increment counter by, 1 by default. Use 0 to check the limit without bumping the counter. |
Definition at line 183 of file RateLimiter.php.
References MediaWiki\Permissions\RateLimitSubject\getIP(), MediaWiki\Permissions\RateLimitSubject\getUser(), MediaWiki\Permissions\RateLimitSubject\is(), and MediaWiki\Permissions\RateLimiter\isExempt().
MediaWiki\Permissions\RateLimiter::setStats | ( | StatsdDataFactoryInterface | $stats | ) |
Definition at line 109 of file RateLimiter.php.
const MediaWiki\Permissions\RateLimiter::CONSTRUCTOR_OPTIONS |
Definition at line 81 of file RateLimiter.php.