@@ -43,14 +43,20 @@ public function handle()
43
43
}
44
44
45
45
if (! $ this ->confirmToProceed ('Checking version deactivated ' , function () {
46
- return $ this ->getLaravel ()->environment () == 'production ' ;
46
+ return $ this ->getLaravel ()->environment () === 'production ' ;
47
47
})) {
48
48
return false ;
49
49
}
50
50
51
51
$ instance = Instance::first ();
52
52
$ instance ->current_version = config ('monica.app_version ' );
53
53
54
+ if ($ instance ->current_version == '' ) {
55
+ Log::warning ('Current instance version is not set, skipping version check. ' );
56
+
57
+ return ;
58
+ }
59
+
54
60
// Query version.monicahq.com
55
61
try {
56
62
$ this ->log ('Call url: ' .config ('monica.weekly_ping_server_url ' ));
@@ -72,10 +78,10 @@ public function handle()
72
78
$ json = $ response ->json ();
73
79
74
80
$ this ->log ('instance version: ' .$ instance ->current_version );
75
- $ this ->log ( ' current version: ' . $ json [ ' latest_version ' ] );
81
+ $ currentVersion = $ this ->getVersion ( $ instance -> current_version );
76
82
77
- $ latestVersion = new Version ( $ json ['latest_version ' ]);
78
- $ currentVersion = new Version ( $ instance -> current_version );
83
+ $ this -> log ( ' current version: ' . $ json ['latest_version ' ]);
84
+ $ latestVersion = $ this -> getVersion ( $ json [ ' latest_version ' ] );
79
85
80
86
if ($ latestVersion > $ currentVersion ) {
81
87
$ instance ->latest_version = $ json ['latest_version ' ];
@@ -93,4 +99,15 @@ public function log($string)
93
99
{
94
100
$ this ->info ($ string , OutputInterface::VERBOSITY_VERBOSE );
95
101
}
102
+
103
+ private function getVersion (string $ version ): ?Version
104
+ {
105
+ try {
106
+ return new Version ($ version );
107
+ } catch (\Exception $ e ) {
108
+ $ this ->error ("Error parsing version ' $ version': " .$ e ->getMessage ());
109
+ }
110
+
111
+ return null ;
112
+ }
96
113
}
0 commit comments