r48648 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r48647‎ | r48648 | r48649 >
Date:00:01, 21 March 2009
Author:brion
Status:ok
Tags:
Comment:
HTTP proxy usage tweaks:
* Use $wgHTTPProxy if set for Special:Upload upload-by-URL (it does its own CURL fetch instead of using Http class)
* Explicitly disable HTTP proxy for MWSearch fetches -- we know that'll be local network.
Modified paths:
  • /trunk/extensions/MWSearch/MWSearch_body.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUpload.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialUpload.php
@@ -155,7 +155,7 @@
156156 * Returns true if there was an error, false otherwise
157157 */
158158 private function curlCopy( $url, $dest ) {
159 - global $wgUser, $wgOut;
 159+ global $wgUser, $wgOut, $wgHTTPProxy;
160160
161161 if( !$wgUser->isAllowed( 'upload_by_url' ) ) {
162162 $wgOut->permissionRequired( 'upload_by_url' );
@@ -183,6 +183,9 @@
184184 curl_setopt( $ch, CURLOPT_TIMEOUT, 10); # 10 seconds timeout
185185 curl_setopt( $ch, CURLOPT_LOW_SPEED_LIMIT, 512); # 0.5KB per second minimum transfer speed
186186 curl_setopt( $ch, CURLOPT_URL, $url);
 187+ if( $wgHTTPProxy ) {
 188+ curl_setopt( $ch, CURLOPT_PROXY, $wgHTTPProxy );
 189+ }
187190 curl_setopt( $ch, CURLOPT_WRITEFUNCTION, array( $this, 'uploadCurlCallback' ) );
188191 curl_exec( $ch );
189192 $error = curl_errno( $ch ) ? true : false;
Index: trunk/extensions/MWSearch/MWSearch_body.php
@@ -463,10 +463,14 @@
464464 }
465465 }
466466
 467+ // Search server will be in local network but may not trigger checks on
 468+ // Http::isLocal(), so suppress usage of $wgHTTPProxy if enabled.
 469+ $curlOpts = array( CURLOPT_PROXY => '' );
 470+
467471 wfDebug( "Fetching search data from $searchUrl\n" );
468472 wfSuppressWarnings();
469473 wfProfileIn( $fname.'-contact-'.$host );
470 - $data = Http::get( $searchUrl, $wgLuceneSearchTimeout );
 474+ $data = Http::get( $searchUrl, $wgLuceneSearchTimeout, $curlOpts );
471475 wfProfileOut( $fname.'-contact-'.$host );
472476 wfRestoreWarnings();
473477 if( $data === false ) {

Status & tagging log