r51784 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51783‎ | r51784 | r51785 >
Date:09:17, 12 June 2009
Author:ialex
Status:ok
Tags:
Comment:
Fixes for r51774:
* declare $ip and $ipchain so that it doesn't throw notices and warnings
* don't set $ip to false after getting it from $_SERVER['REMOTE_ADDR'], otherwise it won't work when there's no XFF header
* fix logic when throwing the exception: throw it when there's no IP
Modified paths:
  • /trunk/phase3/includes/ProxyTools.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ProxyTools.php
@@ -74,6 +74,9 @@
7575 return $wgIP;
7676 }
7777
 78+ $ipchain = array();
 79+ $ip = false;
 80+
7881 /* collect the originating ips */
7982 # Client connecting to this webserver
8083 if ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
@@ -82,8 +85,6 @@
8386 if( $ip ) {
8487 $ipchain[] = $ip;
8588 }
86 -
87 - $ip = false;
8889
8990 # Append XFF on to $ipchain
9091 $forwardedFor = wfGetForwardedFor();
@@ -108,7 +109,7 @@
109110 }
110111 }
111112
112 - if( $ip ) {
 113+ if( !$ip ) {
113114 throw new MWException( "Unable to determine IP" );
114115 }
115116

Follow-up revisions

RevisionCommit summaryAuthorDate
r51785Fix for r51774, r51784: set '127.0.0.1' as IP for CLI, but with explicit chec...ialex09:34, 12 June 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r51774Revert r51725 (fall back to 127.0.0.1 when IP cannot be determined). On furth...demon01:34, 12 June 2009

Status & tagging log