From: Tim Starling Date: Wed, 21 May 2008 03:13:24 +0000 (+0000) Subject: Allow rate limits to be specific to explicit groups X-Git-Tag: 1.31.0-rc.0~47501 X-Git-Url: http://git.cyclocoop.org/data/%24oldEdit?a=commitdiff_plain;h=5ac6ff8294a54bce7994b2eeb55a246609016b99;p=lhc%2Fweb%2Fwiklou.git Allow rate limits to be specific to explicit groups --- diff --git a/includes/User.php b/includes/User.php index d2edfa3e9e..ca88f5dc0c 100644 --- a/includes/User.php +++ b/includes/User.php @@ -1138,13 +1138,14 @@ class User { $keys = array(); $id = $this->getId(); $ip = wfGetIP(); + $userLimit = false; if( isset( $limits['anon'] ) && $id == 0 ) { $keys[wfMemcKey( 'limiter', $action, 'anon' )] = $limits['anon']; } if( isset( $limits['user'] ) && $id != 0 ) { - $keys[wfMemcKey( 'limiter', $action, 'user', $id )] = $limits['user']; + $userLimit = $limits['user']; } if( $this->isNewbie() ) { if( isset( $limits['newbie'] ) && $id != 0 ) { @@ -1159,6 +1160,20 @@ class User { $keys["mediawiki:limiter:$action:subnet:$subnet"] = $limits['subnet']; } } + // Check for group-specific permissions + // If more than one group applies, use the group with the highest limit + foreach ( $this->getGroups() as $group ) { + if ( isset( $limits[$group] ) ) { + if ( $userLimit === false || $limits[$group] > $userLimit ) { + $userLimit = $limits[$group]; + } + } + } + // Set the user limit key + if ( $userLimit !== false ) { + wfDebug( __METHOD__.": effective user limit: $userLimit\n" ); + $keys[ wfMemcKey( 'limiter', $action, 'user', $id ) ] = $userLimit; + } $triggered = false; foreach( $keys as $key => $limit ) {