$summary = "(limit $max in {$period}s)";
$count = $cache->get( $key );
// Already pinged?
- if ( $count ) {
- if ( $count >= $max ) {
- wfDebugLog( 'ratelimit', "User '{$this->getName()}' " .
- "(IP {$this->getRequest()->getIP()}) tripped $key at $count $summary" );
- $triggered = true;
- } else {
- wfDebug( __METHOD__ . ": ok. $key at $count $summary\n" );
- }
+ if ( $count && $count >= $max ) {
+ wfDebugLog( 'ratelimit', "User '{$this->getName()}' " .
+ "(IP {$this->getRequest()->getIP()}) tripped $key at $count $summary" );
+ $triggered = true;
} else {
wfDebug( __METHOD__ . ": adding record for $key $summary\n" );
if ( $incrBy > 0 ) {
}
}
if ( $incrBy > 0 ) {
- $cache->incr( $key, $incrBy );
+ $cache->incrWithInit( $key, (int)$period, $incrBy, $incrBy );
}
}
/**
* Check if user is allowed to access a feature / make an action
*
+ * @deprecated since 1.34, use MediaWikiServices::getInstance()
+ * ->getPermissionManager()->userHasAnyRights(...) instead
+ *
* @param string $permissions,... Permissions to test
* @return bool True if user is allowed to perform *any* of the given actions
*/
public function isAllowedAny() {
- $permissions = func_get_args();
- foreach ( $permissions as $permission ) {
- if ( $this->isAllowed( $permission ) ) {
- return true;
- }
- }
- return false;
+ return MediaWikiServices::getInstance()
+ ->getPermissionManager()
+ ->userHasAnyRight( $this, ...func_get_args() );
}
/**
- *
+ * @deprecated since 1.34, use MediaWikiServices::getInstance()
+ * ->getPermissionManager()->userHasAllRights(...) instead
* @param string $permissions,... Permissions to test
* @return bool True if the user is allowed to perform *all* of the given actions
*/
public function isAllowedAll() {
- $permissions = func_get_args();
- foreach ( $permissions as $permission ) {
- if ( !$this->isAllowed( $permission ) ) {
- return false;
- }
- }
- return true;
+ return MediaWikiServices::getInstance()
+ ->getPermissionManager()
+ ->userHasAllRights( $this, ...func_get_args() );
}
/**
global $wgLang;
$groups = [];
- foreach ( self::getGroupsWithPermission( $permission ) as $group ) {
+ foreach ( MediaWikiServices::getInstance()
+ ->getPermissionManager()
+ ->getGroupsWithPermission( $permission ) as $group ) {
$groups[] = UserGroupMembership::getLink( $group, RequestContext::getMain(), 'wiki' );
}