(bug 13453) Fix rebuildrecentchanges for DB's with FK constraints
[lhc/web/wiklou.git] / includes / ProxyTools.php
index dc30d0e..f76e24f 100644 (file)
@@ -67,23 +67,26 @@ function wfGetAgent() {
  * @return string
  */
 function wfGetIP() {
-       global $wgIP, $wgUsePrivateIPs;
+       global $wgIP, $wgUsePrivateIPs, $wgCommandLineMode;
 
        # Return cached result
        if ( !empty( $wgIP ) ) {
                return $wgIP;
        }
 
+       $ipchain = array();
+       $ip = false;
+
        /* collect the originating ips */
        # Client connecting to this webserver
        if ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
                $ip = IP::canonicalize( $_SERVER['REMOTE_ADDR'] );
+       } elseif( $wgCommandLineMode ) {
+               $ip = '127.0.0.1';
        }
        if( $ip ) {
                $ipchain[] = $ip;
        }
-       
-       $ip = false;
 
        # Append XFF on to $ipchain
        $forwardedFor = wfGetForwardedFor();
@@ -108,7 +111,7 @@ function wfGetIP() {
                }
        }
 
-       if( $ip ) {
+       if( !$ip ) {
                throw new MWException( "Unable to determine IP" );
        }
 
@@ -171,7 +174,7 @@ function wfProxyCheck() {
                                                escapeshellarg( $port ),
                                                escapeshellarg( $url )
                                                ));
-                       exec( "php $params &>/dev/null &" );
+                       exec( "php $params >" . wfGetNull() . " 2>&1 &" );
                }
                # Set MemCached key
                $wgMemc->set( $mcKey, 1, $wgProxyMemcExpiry );