Skip to content

Commit

Permalink
fix: allow RESTAPIVersionReleasesCache to retain existing cache on fa…
Browse files Browse the repository at this point in the history
…ilure #543
  • Loading branch information
jaredhendrickson13 committed Sep 19, 2024
1 parent dc05110 commit 3862871
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ class RESTAPIVersionReleasesCache extends Cache {
* Retrieves available release information from external repos and updates the releases cache files.
*/
public function get_data_to_cache(): array {
# TODO: Change this to use PHP curl instead of a shell command
$fetch_releases_cmd = 'curl -s ' . self::RELEASES_URL . " -m $this->timeout";
$releases_json = new Command($fetch_releases_cmd);
return json_decode($releases_json->output, true);
# Retrieve the available releases from the GitHub API
$releases_json = \RESTAPI\Core\Tools\http_request(url: self::RELEASES_URL, method: 'GET');
$releases = json_decode($releases_json, true);

# Return the fetched releases if in a valid format, otherwise retain the existing cache
return is_array($releases) ? $releases : $this->read();
}
}

0 comments on commit 3862871

Please sign in to comment.