r51774 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51773‎ | r51774 | r51775 >
Date:01:34, 12 June 2009
Author:demon
Status:ok (Comments)
Tags:
Comment:
Revert r51725 (fall back to 127.0.0.1 when IP cannot be determined). On further discussion, it's best if we don't make up a fake IP. Tweak the logic here a bit (per Tim) to let XFF attempt to determine the actual IP. Throw an exception if we can't.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/ProxyTools.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ProxyTools.php
@@ -76,13 +76,14 @@
7777
7878 /* collect the originating ips */
7979 # Client connecting to this webserver
80 - if ( isset( $_SERVER['REMOTE_ADDR'] ) && IP::canonicalize( $_SERVER['REMOTE_ADDR'] ) ) {
81 - $ipchain = array( IP::canonicalize( $_SERVER['REMOTE_ADDR'] ) );
82 - } else {
83 - # Running on CLI or REMOTE_ADDR is broken
84 - $ipchain = array( '127.0.0.1' );
 80+ if ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
 81+ $ip = IP::canonicalize( $_SERVER['REMOTE_ADDR'] );
8582 }
86 - $ip = $ipchain[0];
 83+ if( $ip ) {
 84+ $ipchain[] = $ip;
 85+ }
 86+
 87+ $ip = false;
8788
8889 # Append XFF on to $ipchain
8990 $forwardedFor = wfGetForwardedFor();
@@ -107,6 +108,10 @@
108109 }
109110 }
110111
 112+ if( $ip ) {
 113+ throw new MWException( "Unable to determine IP" );
 114+ }
 115+
111116 wfDebug( "IP: $ip\n" );
112117 $wgIP = $ip;
113118 return $ip;
Index: trunk/phase3/RELEASE-NOTES
@@ -182,8 +182,7 @@
183183 * Multiple whitespace in TOC anchors is now stripped, for consistency with the
184184 link from the edit comment
185185 * (bug 19112) Preferences now respects $wgUseExternalEditor, $wgExternalDiffEngine
186 -* (bug 18173) Login form exception on malformed REMOTE_ADDR, wfGetIP() now falls
187 - back to 127.0.0.1 if the IP cannot be determined
 186+* (bug 18173) MediaWiki now fails on malformed REMOTE_ADDR
188187
189188 == API changes in 1.16 ==
190189

Follow-up revisions

RevisionCommit summaryAuthorDate
r51784Fixes for r51774:...ialex09:17, 12 June 2009
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
r51725(bug 18173) Login form exception on malformed REMOTE_ADDR, wfGetIP() now fall...demon03:20, 11 June 2009

Comments

#Comment by Siebrand (talk | contribs)   07:08, 12 June 2009

Getting the following notices and warning running a commandline tool (/var/www/w/extensions/Translate/scripts/sync-group.php in this case which was not changed recently, and ran fine until a few hours ago):

  • PHP Notice: Undefined variable: ip in /var/www/w/includes/ProxyTools.php on line 82
  • PHP Notice: Undefined variable: ipchain in /var/www/w/includes/ProxyTools.php on line 98
  • PHP Warning: Invalid argument supplied for foreach() in /var/www/w/includes/ProxyTools.php on line 98

Status & tagging log