diff --git a/src/ext/updater/class.updater.php b/src/ext/updater/class.updater.php index 5ea81ed..c74996d 100644 --- a/src/ext/updater/class.updater.php +++ b/src/ext/updater/class.updater.php @@ -2,7 +2,7 @@ /* This file is a part of myTinyTodo. - (C) Copyright 2023 Max Pozdeev + (C) Copyright 2023-2025 Max Pozdeev Licensed under the GNU GPL version 2 or any later. See file COPYRIGHT for details. */ @@ -12,7 +12,7 @@ class Updater { public $lastErrorString = null; - public function lastVersionInfo(): ?array + public function requestJson(string $url): ?string { $options = array( 'http' => array( @@ -26,14 +26,23 @@ class Updater $json = null; $this->lastErrorString = null; try { - $json = @file_get_contents("https://api.github.com/repos/maxpozdeev/mytinytodo/releases", false, $context); + $json = @file_get_contents($url, false, $context); } catch (\Exception $e) { $this->lastErrorString = boolval(ini_get('html_errors')) ? htmlspecialchars_decode($e->getMessage()) : $e->getMessage(); } restore_error_handler(); - if ($json === false || $json == '') { - error_log("Failed to get releases info: ".$this->lastErrorString); + if ($json === false) { + return null; + } + return $json; + } + + public function lastVersionInfo(): ?array + { + $json = $this->requestJson("https://api.github.com/repos/maxpozdeev/mytinytodo/releases"); + if ($json === null || $json == '') { + error_log("Failed to request releases info: ".$this->lastErrorString); return null; } $releases = json_decode($json, true) ?? []; diff --git a/src/ext/updater/extension.json b/src/ext/updater/extension.json index 5b05bcd..7c7889f 100644 --- a/src/ext/updater/extension.json +++ b/src/ext/updater/extension.json @@ -1,6 +1,6 @@ { "bundleId": "updater", "name": "Updates", - "version": "0.9.3", + "version": "0.9.4", "description": "myTinyTodo self-updater" }