From 99ed3c15a00f60fa27b50d2345e4c03a685bf94d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Fri, 26 May 2023 11:38:46 +0300 Subject: [PATCH] Fixed console update `latest` string get version issue.. --- app/Utilities/Versions.php | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/app/Utilities/Versions.php b/app/Utilities/Versions.php index 8136c791a..c58b4bada 100644 --- a/app/Utilities/Versions.php +++ b/app/Utilities/Versions.php @@ -56,7 +56,7 @@ class Versions $versions = static::all($alias); if (empty($versions[$alias])) { - return false; + return static::getVersionByAlias($alias); } return $versions[$alias]; @@ -128,6 +128,30 @@ class Versions return $versions; } + public static function getVersionByAlias($alias) + { + $info = Info::all(); + + // Check core first + $url = 'core/version/' . $info['akaunting'] . '/' . $info['php'] . '/' . $info['mysql'] . '/' . $info['companies']; + $version = $info['akaunting']; + + if ($alias != 'core') { + $version = module($alias)->get('version'); + + $url = 'apps/' . $alias . '/version/' . $version . '/' . $info['akaunting']; + } + + // Get data from cache + $versions = Cache::get('versions', []); + + $versions[$alias] = static::getLatestVersion($url, $version); + + Cache::put('versions', $versions, Date::now()->addHour(6)); + + return $versions[$alias]; + } + public static function getLatestVersion($url, $latest) { $version = new \stdClass();