r90393 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90392‎ | r90393 | r90394 >
Date:12:57, 19 June 2011
Author:ialex
Status:ok
Tags:
Comment:
Moved wfIsLocallyBlockedProxy() to User::isLocallyBlockedProxy() to put it near other proxy checks. No other call to that function in core or extension.

Also added a check to not execute a part of User::getBlockedStatus() if $ip is null.
Modified paths:
  • /trunk/phase3/includes/ProxyTools.php (modified) (history)
  • /trunk/phase3/includes/User.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ProxyTools.php
@@ -179,35 +179,3 @@
180180 $wgMemc->set( $mcKey, 1, $wgProxyMemcExpiry );
181181 }
182182 }
183 -
184 -/**
185 - * Check if an IP address is in the local proxy list
186 - * @return bool
187 - */
188 -function wfIsLocallyBlockedProxy( $ip ) {
189 - global $wgProxyList;
190 -
191 - if ( !$wgProxyList ) {
192 - return false;
193 - }
194 - wfProfileIn( __METHOD__ );
195 -
196 - if ( !is_array( $wgProxyList ) ) {
197 - # Load from the specified file
198 - $wgProxyList = array_map( 'trim', file( $wgProxyList ) );
199 - }
200 -
201 - if ( !is_array( $wgProxyList ) ) {
202 - $ret = false;
203 - } elseif ( array_search( $ip, $wgProxyList ) !== false ) {
204 - $ret = true;
205 - } elseif ( array_key_exists( $ip, $wgProxyList ) ) {
206 - # Old-style flipped proxy list
207 - $ret = true;
208 - } else {
209 - $ret = false;
210 - }
211 - wfProfileOut( __METHOD__ );
212 - return $ret;
213 -}
214 -
Index: trunk/phase3/includes/User.php
@@ -1220,9 +1220,9 @@
12211221 }
12221222
12231223 # Proxy blocking
1224 - if ( !$this->isAllowed( 'proxyunbannable' ) && !in_array( $ip, $wgProxyWhitelist ) ) {
 1224+ if ( $ip !== null && !$this->isAllowed( 'proxyunbannable' ) && !in_array( $ip, $wgProxyWhitelist ) ) {
12251225 # Local list
1226 - if ( wfIsLocallyBlockedProxy( $ip ) ) {
 1226+ if ( self::isLocallyBlockedProxy( $ip ) ) {
12271227 $this->mBlockedby = wfMsg( 'proxyblocker' );
12281228 $this->mBlockreason = wfMsg( 'proxyblockreason' );
12291229 }
@@ -1301,6 +1301,37 @@
13021302 }
13031303
13041304 /**
 1305+ * Check if an IP address is in the local proxy list
 1306+ * @return bool
 1307+ */
 1308+ public static function isLocallyBlockedProxy( $ip ) {
 1309+ global $wgProxyList;
 1310+
 1311+ if ( !$wgProxyList ) {
 1312+ return false;
 1313+ }
 1314+ wfProfileIn( __METHOD__ );
 1315+
 1316+ if ( !is_array( $wgProxyList ) ) {
 1317+ # Load from the specified file
 1318+ $wgProxyList = array_map( 'trim', file( $wgProxyList ) );
 1319+ }
 1320+
 1321+ if ( !is_array( $wgProxyList ) ) {
 1322+ $ret = false;
 1323+ } elseif ( array_search( $ip, $wgProxyList ) !== false ) {
 1324+ $ret = true;
 1325+ } elseif ( array_key_exists( $ip, $wgProxyList ) ) {
 1326+ # Old-style flipped proxy list
 1327+ $ret = true;
 1328+ } else {
 1329+ $ret = false;
 1330+ }
 1331+ wfProfileOut( __METHOD__ );
 1332+ return $ret;
 1333+ }
 1334+
 1335+ /**
13051336 * Is this user subject to rate limiting?
13061337 *
13071338 * @return Bool True if rate limited

Status & tagging log