Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
The update checker can handle the development releases
James Colea2c0d9f7d0a4
diff --git a/app/Events/RequestedVersionCheckStatus.php b/app/Events/RequestedVersionCheckStatus.phpindex d574884f28..63b9f4f898 100644--- a/app/Events/RequestedVersionCheckStatus.php+++ b/app/Events/RequestedVersionCheckStatus.php@@ -34,8 +34,7 @@ class RequestedVersionCheckStatus extends Event{use SerializesModels;- /** @var User The user */- public $user;+ public User $user;/*** Create a new event instance. This event is triggered when Firefly III wants to knowdiff --git a/app/Services/FireflyIIIOrg/Update/UpdateRequest.php b/app/Services/FireflyIIIOrg/Update/UpdateRequest.phpindex 24a10b8f84..cd2de665ee 100644--- a/app/Services/FireflyIIIOrg/Update/UpdateRequest.php+++ b/app/Services/FireflyIIIOrg/Update/UpdateRequest.php@@ -28,6 +28,7 @@ use Carbon\Carbon;use FireflyIII\Events\NewVersionAvailable;use GuzzleHttp\Client;use GuzzleHttp\Exception\GuzzleException;+use Illuminate\Support\Facades\Log;/*** Class UpdateRequest@@ -42,8 +43,8 @@ class UpdateRequest implements UpdateRequestInterface'message' => (string)trans('firefly.unknown_error'),];- // try get array from update server:- $updateInfo = $this->contactServer($channel);+ // try to get array from update server:+ $updateInfo = $this->contactServer($channel);if ('error' === $updateInfo['level']) {app('log')->error('Update information contains an error.');app('log')->error($updateInfo['message']);@@ -60,14 +61,14 @@ class UpdateRequest implements UpdateRequestInterface{app('log')->debug(sprintf('Now in contactServer(%s)', $channel));// always fall back to current version:- $return = [+ $return = ['version' => config('firefly.version'),'date' => today(config('app.timezone'))->startOfDay(),'level' => 'error','message' => (string)trans('firefly.unknown_error'),];- $url = config('firefly.update_endpoint');+ $url = config('firefly.update_endpoint');app('log')->debug(sprintf('Going to call %s', $url));try {@@ -95,7 +96,7 @@ class UpdateRequest implements UpdateRequestInterfacereturn $return;}- $body = (string)$res->getBody();+ $body = (string)$res->getBody();try {$json = json_decode($body, true, 512, JSON_THROW_ON_ERROR);@@ -114,8 +115,8 @@ class UpdateRequest implements UpdateRequestInterface}// parse response a bit. No message yet.- $response = $json['firefly_iii'][$channel];- $date = Carbon::createFromFormat('Y-m-d', $response['date']);+ $response = $json['firefly_iii'][$channel];+ $date = Carbon::createFromFormat('Y-m-d', $response['date']);if (false === $date) {$date = today(config('app.timezone'));}@@ -131,19 +132,35 @@ class UpdateRequest implements UpdateRequestInterfaceprivate function parseResult(array $information): array{app('log')->debug('Now in parseResult()', $information);- $return = [+ $return = ['level' => 'error','message' => (string)trans('firefly.unknown_error'),];- $current = config('firefly.version');- $latest = $information['version'];+ $current = config('firefly.version');+ $latest = $information['version'];// strip the 'v' from the version if it's there.if (str_starts_with($latest, 'v')) {$latest = substr($latest, 1);}+ if (str_starts_with($current, 'develop')) {+ Log::debug(sprintf('User is running develop version "%s"', $current));+ $parts = explode('/', $current);+ $devDate = Carbon::createFromFormat('Y-m-d', $parts[1]);++ if ($devDate->lte($information['date'])) {+ Log::debug(sprintf('This development release is older, release = %s, latest version %s = %s', $devDate->format('Y-m-d'), $latest, $information['date']->format('Y-m-d')));+ $return['level'] = 'info';+ $return['message'] = (string)trans('firefly.update_current_dev_older', ['version' => $current, 'new_version' => $latest]);+ return $return;+ }+ Log::debug(sprintf('This development release is newer, release = %s, latest version %s = %s', $devDate->format('Y-m-d'), $latest, $information['date']->format('Y-m-d')));+ $return['level'] = 'info';+ $return['message'] = (string)trans('firefly.update_current_dev_newer', ['version' => $current, 'new_version' => $latest]);+ return $return;+ }- $compare = version_compare($latest, $current);+ $compare = version_compare($latest, $current);app('log')->debug(sprintf('Current version is "%s", latest is "%s", result is: %d', $current, $latest, $compare));@@ -166,10 +183,10 @@ class UpdateRequest implements UpdateRequestInterface// a newer version is available!/** @var Carbon $released */- $released = $information['date'];- $today = today(config('app.timezone'))->startOfDay();- $diff = $today->diffInDays($released);- $expectedDiff = config('firefly.update_minimum_age') ?? 6;+ $released = $information['date'];+ $today = today(config('app.timezone'))->startOfDay();+ $diff = $today->diffInDays($released);+ $expectedDiff = config('firefly.update_minimum_age') ?? 6;// it's still very fresh, and user wants a stable release:if ($diff <= $expectedDiff) {$return['level'] = 'info';@@ -200,13 +217,13 @@ class UpdateRequest implements UpdateRequestInterface// add warning in case of alpha or beta:// append warning if beta or alpha.- $isBeta = $information['is_beta'] ?? false;+ $isBeta = $information['is_beta'] ?? false;if (true === $isBeta) {$return['message'] = sprintf('%s %s', $return['message'], trans('firefly.update_version_beta'));app('log')->debug('New release is also a beta!');}- $isAlpha = $information['is_alpha'] ?? false;+ $isAlpha = $information['is_alpha'] ?? false;if (true === $isAlpha) {$return['message'] = sprintf('%s %s', $return['message'], trans('firefly.update_version_alpha'));app('log')->debug('New release is also a alpha!');diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.phpindex 597f1034f6..4f1691bb69 100644--- a/resources/lang/en_US/firefly.php+++ b/resources/lang/en_US/firefly.php@@ -308,6 +308,8 @@ return ['update_new_version_alert' => 'A new version of Firefly III is available. You are running :your_version, the latest version is :new_version which was released on :date.','update_version_beta' => 'This version is a BETA version. You may run into issues.','update_version_alpha' => 'This version is a ALPHA version. You may run into issues.',+ 'update_current_dev_older' => 'You are running development release ":version", which is older than the latest release :new_version. Please update!',+ 'update_current_dev_newer' => 'You are running development release ":version", which is newer than the latest release :new_version.','update_current_version_alert' => 'You are running :version, which is the latest available release.','update_newer_version_alert' => 'You are running :your_version, which is newer than the latest release, :new_version.','update_check_error' => 'An error occurred while checking for updates: :error',