From 559880b4f437a163b71c1dc165db3e64b0486452 Mon Sep 17 00:00:00 2001 From: GlazerMann Date: Sat, 20 Jan 2024 14:20:43 -0600 Subject: [PATCH] deal with 503 errors --- expandFns.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/expandFns.php b/expandFns.php index 9522d3d509..8b2f57a8f4 100644 --- a/expandFns.php +++ b/expandFns.php @@ -122,15 +122,16 @@ function is_doi_active(string $doi) : ?bool { CURLOPT_URL => $url ]); $headers_test = @curl_exec($ch); - if ($headers_test === FALSE) { - sleep(2); // @codeCoverageIgnore - report_inline(' .'); // @codeCoverageIgnore - $headers_test = @curl_exec($ch); // @codeCoverageIgnore + if ($headers_test === FALSE || (curl_getinfo($ch, CURLINFO_RESPONSE_CODE) === 503)) { + sleep(4); + report_inline(' .'); + $headers_test = @curl_exec($ch); } if ($headers_test === FALSE) return NULL; // most likely bad, but will recheck again an again $response_code = curl_getinfo($ch, CURLINFO_RESPONSE_CODE); if ($response_code === 200) return TRUE; if ($response_code === 404) return FALSE; + if ($response_code === 503) return NULL; $err = "CrossRef server error loading headers for DOI " . echoable($doi . " : " . (string) $response_code); // @codeCoverageIgnore bot_debug_log($err); // @codeCoverageIgnore report_warning($err); // @codeCoverageIgnore