Capture app version and defer notifications

Installer: capture the current app version (fromVersion) before running migrations, with a fallback for very old installs where settings may not exist. Re-read the app version after migrations to determine toVersion and only use migration-based detection as a fallback when the version didn't change.

Update flow: only send admin upgrade notifications when there are no pending migrations. If migrations remain, the user is redirected to the installer which will send the correct notification after migrations complete. This prevents duplicate or incorrect upgrade notifications and ensures accurate from/to version reporting.
This commit is contained in:
Hosteroid
2026-02-11 18:44:06 +02:00
parent 3688c8b71b
commit 4371f174c9
2 changed files with 43 additions and 30 deletions

View File

@@ -109,20 +109,24 @@ class UpdateController extends Controller
// Check for pending migrations after file update
$hasMigrations = $this->updateService->hasPendingMigrations();
// Notify admins
try {
$notificationService = new NotificationService();
$notificationService->notifyAdminsUpgrade(
$fromVersion,
$toVersion,
0,
!empty($result['composer_manual_required'])
);
} catch (\Exception $e) {
// Non-critical
$this->logger->warning('Failed to send upgrade notification', [
'error' => $e->getMessage(),
]);
// Only notify admins if there are NO pending migrations.
// When migrations are pending, the user is redirected to /install/update
// which sends the upgrade notification after migrations complete (with the correct count).
if (!$hasMigrations) {
try {
$notificationService = new NotificationService();
$notificationService->notifyAdminsUpgrade(
$fromVersion,
$toVersion,
0,
!empty($result['composer_manual_required'])
);
} catch (\Exception $e) {
// Non-critical
$this->logger->warning('Failed to send upgrade notification', [
'error' => $e->getMessage(),
]);
}
}
$message = "Update applied successfully! {$filesUpdated} file(s) updated.";