X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FHttpFunctions.php;h=b12f49f0b0f7a55aab1c94e1e51baaa577d28b04;hb=1b6d9eeaea71ef4cd2b99f9a97b9aa538c48aad4;hp=f980a93d56e2f83fcb40e1894435f4f7d6124201;hpb=a25d6fbc285077bd3dc1ae8cc1fe50a3766b8ae7;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/HttpFunctions.php b/includes/HttpFunctions.php index f980a93d56..b12f49f0b0 100644 --- a/includes/HttpFunctions.php +++ b/includes/HttpFunctions.php @@ -80,7 +80,7 @@ class Http { } else { $errors = $status->getErrorsByType( 'error' ); $logger = LoggerFactory::getInstance( 'http' ); - $logger->warning( $status->getWikiText( null, null, 'en' ), + $logger->warning( $status->getWikiText( false, false, 'en' ), [ 'error' => $errors, 'caller' => $caller, 'content' => $req->getContent() ] ); return false; } @@ -192,6 +192,26 @@ class Http { $uri ); } + + /** + * Gets the relevant proxy from $wgHTTPProxy/http_proxy (when set). + * + * @return mixed The proxy address or an empty string if not set. + */ + public static function getProxy() { + global $wgHTTPProxy; + + if ( $wgHTTPProxy ) { + return $wgHTTPProxy; + } + + $envHttpProxy = getenv( "http_proxy" ); + if ( $envHttpProxy ) { + return $envHttpProxy; + } + + return ""; + } } /** @@ -368,8 +388,6 @@ class MWHttpRequest { * @return void */ public function proxySetup() { - global $wgHTTPProxy; - // If there is an explicit proxy set and proxies are not disabled, then use it if ( $this->proxy && !$this->noProxy ) { return; @@ -379,10 +397,8 @@ class MWHttpRequest { // local URL and proxies are not disabled if ( Http::isLocalURL( $this->url ) || $this->noProxy ) { $this->proxy = ''; - } elseif ( $wgHTTPProxy ) { - $this->proxy = $wgHTTPProxy; - } elseif ( getenv( "http_proxy" ) ) { - $this->proxy = getenv( "http_proxy" ); + } else { + $this->proxy = Http::getProxy(); } } @@ -991,7 +1007,7 @@ class PhpHttpRequest extends MWHttpRequest { ]; if ( $this->proxy ) { - $options['http']['proxy'] = $this->urlToTCP( $this->proxy ); + $options['http']['proxy'] = $this->urlToTcp( $this->proxy ); $options['http']['request_fulluri'] = true; }