r41158 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41157‎ | r41158 | r41159 >
Date:15:44, 22 September 2008
Author:demon
Status:old
Tags:
Comment:
Make file_get_contents() respect our timeout settings. Otherwise, we'll get 3 minute waits for timeouts potentially, which is icky.
Modified paths:
  • /trunk/phase3/includes/HttpFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/HttpFunctions.php
@@ -27,6 +27,11 @@
2828 static function request( $method, $url, $timeout = 'default', $curlOptions = array() ) {
2929 global $wgHTTPTimeout, $wgHTTPProxy, $wgVersion, $wgTitle;
3030
 31+ // Go ahead and set the timeout if not otherwise specified
 32+ if ( $timeout == 'default' ) {
 33+ $timeout = $wgHTTPTimeout;
 34+ }
 35+
3136 wfDebug( __METHOD__ . ": $method $url\n" );
3237 # Use curl if available
3338 if ( function_exists( 'curl_init' ) ) {
@@ -37,9 +42,6 @@
3843 curl_setopt($c, CURLOPT_PROXY, $wgHTTPProxy);
3944 }
4045
41 - if ( $timeout == 'default' ) {
42 - $timeout = $wgHTTPTimeout;
43 - }
4446 curl_setopt( $c, CURLOPT_TIMEOUT, $timeout );
4547 curl_setopt( $c, CURLOPT_USERAGENT, "MediaWiki/$wgVersion" );
4648 if ( $method == 'POST' )
@@ -78,7 +80,7 @@
7981 curl_close( $c );
8082 } else {
8183 # Otherwise use file_get_contents...
82 - # This may take 3 minutes to time out, and doesn't have local fetch capabilities
 84+ # This doesn't have local fetch capabilities...
8385
8486 global $wgVersion;
8587 $headers = array( "User-Agent: MediaWiki/$wgVersion" );
@@ -89,7 +91,8 @@
9092 $opts = array(
9193 'http' => array(
9294 'method' => $method,
93 - 'header' => implode( "\r\n", $headers ) ) );
 95+ 'header' => implode( "\r\n", $headers ),
 96+ 'timeout' => $timeout ) );
9497 $ctx = stream_context_create($opts);
9598
9699 $url_fopen = ini_set( 'allow_url_fopen', 1 );

Status & tagging log