Added $wgHTTPImportTimeout setting
authorrlot <rj23@protonmail.com>
Mon, 2 Jan 2017 19:00:53 +0000 (20:00 +0100)
committerrlot <rj23@protonmail.com>
Tue, 3 Jan 2017 06:34:58 +0000 (07:34 +0100)
Bug: T17000
Change-Id: Ic97ae4faec173c32af38df4554831dca7068226b

RELEASE-NOTES-1.29
includes/DefaultSettings.php
includes/import/ImportStreamSource.php

index 14b5692..9fc0cbe 100644 (file)
@@ -35,6 +35,8 @@ production.
   exceptions, largely so the API can handle them more sensibly.
 * Blocks created automatically by MediaWiki, such as for configured proxies or
   dnsbls, are now indicated as such and use a new i18n message when displayed.
+* Added new $wgHTTPImportTimeout setting. Sets timeout for
+  downloading the XML dump during a transwiki import in seconds.
 
 === External library changes in 1.29 ===
 
index 3274480..449e1c2 100644 (file)
@@ -8055,6 +8055,12 @@ $wgShellLocale = 'en_US.utf8';
  */
 $wgHTTPTimeout = 25;
 
+/**
+ * Timeout for HTTP requests done internally for transwiki imports, in seconds.
+ * @since 1.29
+ */
+$wgHTTPImportTimeout = 25;
+
 /**
  * Timeout for Asynchronous (background) HTTP requests, in seconds.
  */
index e2e8dd5..0c12ebb 100644 (file)
@@ -104,12 +104,21 @@ class ImportStreamSource implements ImportSource {
         * @return Status
         */
        static function newFromURL( $url, $method = 'GET' ) {
+               global $wgHTTPImportTimeout;
                wfDebug( __METHOD__ . ": opening $url\n" );
                # Use the standard HTTP fetch function; it times out
                # quicker and sorts out user-agent problems which might
                # otherwise prevent importing from large sites, such
                # as the Wikimedia cluster, etc.
-               $data = Http::request( $method, $url, [ 'followRedirects' => true ], __METHOD__ );
+               $data = Http::request(
+                       $method,
+                       $url,
+                       [
+                               'followRedirects' => true,
+                               'timeout' => $wgHTTPImportTimeout
+                       ],
+                       __METHOD__
+               );
                if ( $data !== false ) {
                        $file = tmpfile();
                        fwrite( $file, $data );