Addshore has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/373526 )

Change subject: Use CopyUploadTimeout setting
......................................................................

Use CopyUploadTimeout setting

It's rather hard ot keep testing this extension
while you have unreliable & slow wifi unless you
can modify the timeout for requests!

Change-Id: I2e86d33ba4b0bb96644589435d9d0dd0f8955c19
---
M src/ServiceWiring.php
M src/Services/Http/HttpRequestExecutor.php
2 files changed, 14 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/FileImporter 
refs/changes/26/373526/1

diff --git a/src/ServiceWiring.php b/src/ServiceWiring.php
index 4504849..6910d24 100644
--- a/src/ServiceWiring.php
+++ b/src/ServiceWiring.php
@@ -29,8 +29,12 @@
        },
 
        'FileImporterHttpRequestExecutor' => function ( MediaWikiServices 
$services ) {
+               $timeout = $services->getMainConfig()->get( 'CopyUploadTimeout' 
);
                $maxFileSize = UploadBase::getMaxUploadSize( 'import' );
-               $service = new HttpRequestExecutor( $maxFileSize );
+               $service = new HttpRequestExecutor(
+                       $timeout,
+                       $maxFileSize
+               );
                $service->setLogger( LoggerFactory::getInstance( 'FileImporter' 
) );
                return $service;
        },
diff --git a/src/Services/Http/HttpRequestExecutor.php 
b/src/Services/Http/HttpRequestExecutor.php
index fe2b933..f35ad95 100644
--- a/src/Services/Http/HttpRequestExecutor.php
+++ b/src/Services/Http/HttpRequestExecutor.php
@@ -22,17 +22,24 @@
        private $requestFactoryCallable;
 
        /**
+        * @var int
+        */
+       private $timeout;
+
+       /**
         * @var int|null
         */
        private $maxFileSize;
 
        /**
+        * @param int $timeout of http requests in seconds
         * @param int|null $maxFileSize in bytes
         */
-       public function __construct( $maxFileSize = null ) {
+       public function __construct( $timeout, $maxFileSize = null ) {
                $this->requestFactoryCallable = [ MWHttpRequest::class, 
'factory' ];
                $this->logger = new NullLogger();
                $this->maxFileSize = $maxFileSize;
+               $this->timeout = $timeout;
        }
 
        public function setLogger( LoggerInterface $logger ) {
@@ -73,7 +80,6 @@
 
        /**
         * TODO proxy? $wgCopyUploadProxy ?
-        * TODO timeout $wgCopyUploadTimeout ?
         *
         * @param string $url
         * @param callable|null $callback
@@ -89,6 +95,7 @@
                        [
                                'logger' => $this->logger,
                                'followRedirects' => true,
+                               'timeout' => $this->timeout,
                        ],
                        __METHOD__
                );

-- 
To view, visit https://gerrit.wikimedia.org/r/373526
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2e86d33ba4b0bb96644589435d9d0dd0f8955c19
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/FileImporter
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to