Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Less chatty and less checking now #4403

Merged
merged 2 commits into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -6619,11 +6619,12 @@ public function verify_doi() : bool {
if (!$doi) return FALSE;
if ($this->doi_valid) return TRUE;
if ($last_doi === $doi) {
report_info("Rechecking if DOI " . echoable($doi) . " is operational..."); // Sometimes we get NULL, so check again for FALSE/TRUE
$chatty = FALSE;
} else {
$last_doi = $doi;
report_info("Checking that DOI " . echoable($doi) . " is operational...");
$chatty = TRUE;
}
if ($chatty) report_info("Checking that DOI " . echoable($doi) . " is operational...");
$trial = get_possible_dois($doi);
foreach ($trial as $try) {
// Check that it begins with 10.
Expand All @@ -6633,7 +6634,7 @@ public function verify_doi() : bool {
$this->doi_valid = TRUE;
foreach (DOI_BROKEN_ALIASES as $alias) $this->forget($alias);
if ($doi === $try) {
report_inline('DOI ok.');
if ($chatty) report_inline('DOI ok.');
} else {
report_info("Modified DOI: " . echoable($try) . " is operational...");
}
Expand All @@ -6648,7 +6649,7 @@ public function verify_doi() : bool {
$this->doi_valid = TRUE;
foreach (DOI_BROKEN_ALIASES as $alias) $this->forget($alias);
if ($doi === $try) {
report_inline('DOI ok.');
if ($chatty) report_inline('DOI ok.');
} else {
report_info("Modified DOI: " . echoable($try) . " is operational...");
}
Expand All @@ -6660,15 +6661,15 @@ public function verify_doi() : bool {
report_warning("DOI status unknown. doi.org failed to respond to: " . doi_link($doi)); // @codeCoverageIgnore
return FALSE; // @codeCoverageIgnore
} elseif ($doi_status === FALSE) {
report_inline("It's not...");
if ($chatty) report_inline("It's not...");
$this->add_if_new('doi-broken-date', date("Y-m-d"));
return FALSE;
} else {
// Only get to this code if we got NULL earlier and now suddenly get OK
// @codeCoverageIgnoreStart
foreach (DOI_BROKEN_ALIASES as $alias) $this->forget($alias);
$this->doi_valid = TRUE;
report_inline('DOI ok.');
if ($chatty) report_inline('DOI ok.');
return TRUE;
// @codeCoverageIgnoreEnd
}
Expand Down
6 changes: 3 additions & 3 deletions expandFns.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function is_doi_active(string $doi) : ?bool {
sleep(4);
$headers_test = @curl_exec($ch);
}
if ($headers_test === FALSE) return NULL; // most likely bad, but will recheck again an again
if ($headers_test === FALSE) return NULL; // most likely bad
$response_code = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
if ($response_code === 200) return TRUE;
if ($response_code === 404) return FALSE;
Expand Down Expand Up @@ -192,7 +192,7 @@ function is_doi_works(string $doi) : ?bool {
$headers_test = get_headers_array($url); // @codeCoverageIgnore
}
if ($headers_test === FALSE) {
return NULL; // most likely bad, but will recheck again and again - note that NULL means do not add or remove doi-broken-date from pages
return NULL; // most likely bad - note that NULL means do not add or remove doi-broken-date from pages
}
if (interpret_doi_header($headers_test) !== FALSE) {
return interpret_doi_header($headers_test);
Expand Down Expand Up @@ -1439,7 +1439,7 @@ function is_hdl_works(string $hdl) : string|null|false {
if ($headers_test === FALSE) {
$headers_test = get_headers_array($url); // @codeCoverageIgnore
}
if ($headers_test === FALSE) return NULL; // most likely bad, but will recheck again and again
if ($headers_test === FALSE) return NULL; // most likely bad
if (interpret_doi_header($headers_test) === NULL) return NULL;
if (interpret_doi_header($headers_test) === FALSE) return FALSE;
return get_loc_from_hdl_header($headers_test);
Expand Down
Loading