Skip to content

Commit f17690f

Browse files
committed
Extension Manager: set a larger timeout
When loading large plugins, like the dw2pdf plugin, a timout of 25 seconds may not be enough on slow connections. This increases the limit to 5 second short of 4 minutes. On CLI this should not be an issue at all, on web SAPIs we need to increase the execution time first, only if that succeeds (might be disabled on some hosts) the limit is increased. This replaces PR dokuwiki#4377
1 parent 01b2a28 commit f17690f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/plugins/extension/Installer.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,17 @@ public function downloadArchive($url)
288288
// download
289289
$http = new DokuHTTPClient();
290290
$http->max_bodysize = 0;
291-
$http->timeout = 25; //max. 25 sec
292291
$http->keep_alive = false; // we do single ops here, no need for keep-alive
293292
$http->agent = 'DokuWiki HTTP Client (Extension Manager)';
294293

294+
// large downloads may take a while on slow connections, so we try to extend the timeout to 4 minutes
295+
// 4 minutes was chosen, because HTTP servers and proxies often have a 5 minute timeout
296+
if (php_sapi_name() === 'cli' || @set_time_limit(60 * 4)) {
297+
$http->timeout = 60 * 4 - 5; // nearly 4 minutes
298+
} else {
299+
$http->timeout = 25; // max. 25 sec (a bit less than default execution time)
300+
}
301+
295302
$data = $http->get($url);
296303
if ($data === false) throw new Exception('error_download', [$url, $http->error, $http->status]);
297304

0 commit comments

Comments
 (0)