Since the whole flow for long-time-lurkers first-time-contributors is just broken, here’s a patch directly.
Author: SirBacon <[email protected]>
Date: Wed Apr 10 18:31:28 2019 -0700
fetch_file_contents: Fix retry
Detect a failed curl_exec immediately, and possibly attempt a
retry with a forced encoding identity encoding.
This fixes incorrectly attempting to parse false as a string,
as well as the retry filling $contents with the complete reply
including headers (without splitting off and parsing the headers).
diff --git a/include/functions.php b/include/functions.php
index c09e62cca..a66474d13 100755
--- a/include/functions.php
+++ b/include/functions.php
@@ -386,6 +386,20 @@
curl_setopt($ch, CURLOPT_USERPWD, "$login:$pass");
$ret = @curl_exec($ch);
+ if ($ret === false) {
+ // Possibly a gzip issue makes curl unhappy.
+ if (curl_errno($ch) === 23 || curl_errno($ch) === 61) {
+ // Docs say 'identity,' but 'none' seems to work.
+ curl_setopt($ch, CURLOPT_ENCODING, 'none');
+ $ret = @curl_exec($ch);
+ if ($ret === false) {
+ // Give up.
+ $fetch_last_error = curl_errno($ch) . " " . curl_error($ch);
+ curl_close($ch);
+ return false;
+ }
+ }
+ }
$headers_length = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$headers = explode("\r\n", substr($ret, 0, $headers_length));
@@ -406,11 +420,6 @@
}
}
- if (curl_errno($ch) === 23 || curl_errno($ch) === 61) {
- curl_setopt($ch, CURLOPT_ENCODING, 'none');
- $contents = @curl_exec($ch);
- }
-
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$fetch_last_content_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);