Make upload-by-URL fetch timeout configurable as $wgCopyUploadTimeout, default to...
authorBrion Vibber <brion@users.mediawiki.org>
Fri, 27 Mar 2009 17:42:05 +0000 (17:42 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Fri, 27 Mar 2009 17:42:05 +0000 (17:42 +0000)
includes/DefaultSettings.php
includes/specials/SpecialUpload.php

index 94a0dee..28cbfc8 100644 (file)
@@ -428,6 +428,8 @@ $wgSharedUploadDBprefix = '';
 $wgCacheSharedUploads = true;
 /** Allow for upload to be copied from an URL. Requires Special:Upload?source=web */
 $wgAllowCopyUploads = false;
+$wgCopyUploadTimeout = 30; // 30 seconds default timeout for upload-by-URL
+
 /**
  * Max size for uploads, in bytes.  Currently only works for uploads from URL
  * via CURL (see $wgAllowCopyUploads).  The only way to impose limits on
index ab81e4f..4473027 100644 (file)
@@ -155,7 +155,7 @@ class UploadForm {
         * Returns true if there was an error, false otherwise
         */
        private function curlCopy( $url, $dest ) {
-               global $wgUser, $wgOut, $wgHTTPProxy;
+               global $wgUser, $wgOut, $wgHTTPProxy, $wgCopyUploadTimeout;
 
                if( !$wgUser->isAllowed( 'upload_by_url' ) ) {
                        $wgOut->permissionRequired( 'upload_by_url' );
@@ -180,7 +180,7 @@ class UploadForm {
 
                $ch = curl_init();
                curl_setopt( $ch, CURLOPT_HTTP_VERSION, 1.0); # Probably not needed, but apparently can work around some bug
-               curl_setopt( $ch, CURLOPT_TIMEOUT, 10); # 10 seconds timeout
+               curl_setopt( $ch, CURLOPT_TIMEOUT, $wgCopyUploadTimeout); # Default 30 seconds timeout
                curl_setopt( $ch, CURLOPT_LOW_SPEED_LIMIT, 512); # 0.5KB per second minimum transfer speed
                curl_setopt( $ch, CURLOPT_URL, $url);
                if( $wgHTTPProxy ) {