@@ -146,6 +146,13 @@ public function handle(): void
146146 // Notify users
147147 $ connection ->notificationSuccess (["fromVersion " => $ healthResult ->cms_version , "toVersion " => $ this ->targetVersion ]);
148148
149+ // Done, log successful update!
150+ $ this ->site ->updates ()->create ([
151+ 'old_version ' => $ this ->site ->cms_version ,
152+ 'new_version ' => $ this ->targetVersion ,
153+ 'result ' => true
154+ ]);
155+
149156 // Trigger site health check to write the update version back to the db
150157 CheckSiteHealth::dispatch ($ this ->site );
151158 }
@@ -193,13 +200,6 @@ protected function performExtraction(PrepareUpdate $prepareResult): void
193200 "task " => "finalizeUpdate "
194201 ]
195202 );
196-
197- // Done, log successful update!
198- $ this ->site ->updates ()->create ([
199- 'old_version ' => $ this ->site ->cms_version ,
200- 'new_version ' => $ this ->targetVersion ,
201- 'result ' => true
202- ]);
203203 }
204204
205205 public function failed (\Exception $ exception ): void
@@ -212,17 +212,29 @@ public function failed(\Exception $exception): void
212212 /** @var Connection $connection */
213213 $ connection = $ this ->site ->connection ;
214214
215+ // Get base execption information
216+ $ failedStep = $ exception instanceof UpdateException ? $ exception ->getStep () : null ;
217+ $ failedMessage = $ exception ->getMessage ();
218+ $ failedTrace = $ exception ->getTraceAsString ();
219+
215220 // Notify users
216- $ connection ->notificationFailed (["fromVersion " => $ this ->site ->cms_version , "toVersion " => $ this ->targetVersion ]);
221+ try {
222+ $ connection ->notificationFailed (["fromVersion " => $ this ->site ->cms_version , "toVersion " => $ this ->targetVersion ]);
223+ } catch (\Throwable $ e ) {
224+ // If the notification fails, we have to catch the exception and combine both errors into a combined result
225+ $ failedStep .= " + notificationFailed " ;
226+ $ failedMessage .= " + " . $ e ->getMessage ();
227+ $ failedTrace .= " + " . $ e ->getTraceAsString ();
228+ }
217229
218230 // We log any issues during the update to the DB
219231 $ this ->site ->updates ()->create ([
220232 'old_version ' => $ this ->site ->cms_version ,
221233 'new_version ' => $ this ->targetVersion ,
222234 'result ' => false ,
223- 'failed_step ' => $ exception instanceof UpdateException ? $ exception -> getStep () : null ,
224- 'failed_message ' => $ exception -> getMessage () ,
225- 'failed_trace ' => $ exception -> getTraceAsString ()
235+ 'failed_step ' => $ failedStep ,
236+ 'failed_message ' => $ failedMessage ,
237+ 'failed_trace ' => $ failedTrace
226238 ]);
227239 }
228240}
0 commit comments