r35130 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r35129‎ | r35130 | r35131 >
Date:03:13, 21 May 2008
Author:tstarling
Status:old
Tags:
Comment:
Allow rate limits to be specific to explicit groups
Modified paths:
  • /trunk/phase3/includes/User.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/User.php
@@ -1138,13 +1138,14 @@
11391139 $keys = array();
11401140 $id = $this->getId();
11411141 $ip = wfGetIP();
 1142+ $userLimit = false;
11421143
11431144 if( isset( $limits['anon'] ) && $id == 0 ) {
11441145 $keys[wfMemcKey( 'limiter', $action, 'anon' )] = $limits['anon'];
11451146 }
11461147
11471148 if( isset( $limits['user'] ) && $id != 0 ) {
1148 - $keys[wfMemcKey( 'limiter', $action, 'user', $id )] = $limits['user'];
 1149+ $userLimit = $limits['user'];
11491150 }
11501151 if( $this->isNewbie() ) {
11511152 if( isset( $limits['newbie'] ) && $id != 0 ) {
@@ -1159,6 +1160,20 @@
11601161 $keys["mediawiki:limiter:$action:subnet:$subnet"] = $limits['subnet'];
11611162 }
11621163 }
 1164+ // Check for group-specific permissions
 1165+ // If more than one group applies, use the group with the highest limit
 1166+ foreach ( $this->getGroups() as $group ) {
 1167+ if ( isset( $limits[$group] ) ) {
 1168+ if ( $userLimit === false || $limits[$group] > $userLimit ) {
 1169+ $userLimit = $limits[$group];
 1170+ }
 1171+ }
 1172+ }
 1173+ // Set the user limit key
 1174+ if ( $userLimit !== false ) {
 1175+ wfDebug( __METHOD__.": effective user limit: $userLimit\n" );
 1176+ $keys[ wfMemcKey( 'limiter', $action, 'user', $id ) ] = $userLimit;
 1177+ }
11631178
11641179 $triggered = false;
11651180 foreach( $keys as $key => $limit ) {

Status & tagging log