From 30a139d7650696bb89c4f65454e07695d1a28c4b Mon Sep 17 00:00:00 2001 From: Hosteroid Date: Wed, 11 Feb 2026 19:24:39 +0200 Subject: [PATCH] Handle hotfix updates and stale commit cache Treat file-only/hotfix updates (identified by commit SHA) as non-version changes and clear stale commit-cache so the UI no longer reports an available update after a hotfix. UpdateService now clears commits_behind_count and latest_remote_sha when no new commits are found. LayoutHelper and settings view consider installed_commit_sha vs latest_remote_sha and set commitsBehind to 0 when they match. NotificationService detects commit SHAs for the target version and emits a clearer "hotfix {sha}" message for file-only updates. --- app/Helpers/LayoutHelper.php | 7 +++++++ app/Services/NotificationService.php | 9 ++++++++- app/Services/UpdateService.php | 5 +++++ app/Views/settings/index.php | 6 ++++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/app/Helpers/LayoutHelper.php b/app/Helpers/LayoutHelper.php index 170365f..4ef362f 100644 --- a/app/Helpers/LayoutHelper.php +++ b/app/Helpers/LayoutHelper.php @@ -204,6 +204,13 @@ class LayoutHelper $latestVersion = $updateSettings['latest_available_version'] ?? null; $channel = $updateSettings['update_channel'] ?? 'stable'; $commitsBehind = (int) ($updateSettings['commits_behind_count'] ?? 0); + $installedSha = $updateSettings['installed_commit_sha'] ?? ''; + $remoteSha = $updateSettings['latest_remote_sha'] ?? ''; + + // If installed SHA matches remote SHA, the cached commits_behind is stale + if ($installedSha !== '' && $remoteSha !== '' && str_starts_with($installedSha, $remoteSha)) { + $commitsBehind = 0; + } $available = false; $label = ''; diff --git a/app/Services/NotificationService.php b/app/Services/NotificationService.php index d45e6c2..ad035f4 100644 --- a/app/Services/NotificationService.php +++ b/app/Services/NotificationService.php @@ -574,7 +574,14 @@ class NotificationService public function notifySystemUpgrade(int $userId, string $fromVersion, string $toVersion, int $migrationsCount, bool $composerManualRequired = false): void { $migrationLabel = $migrationsCount . ' migration' . ($migrationsCount !== 1 ? 's' : '') . ' applied'; - if ($fromVersion === $toVersion) { + + // Detect if $toVersion is a commit SHA (7-40 hex chars) rather than a semver string + $isCommitSha = (bool) preg_match('/^[a-f0-9]{7,40}$/i', $toVersion); + + if ($isCommitSha) { + // Hotfix: file-only update identified by commit SHA + $message = "Domain Monitor v{$fromVersion} has been updated (hotfix {$toVersion}, {$migrationLabel})"; + } elseif ($fromVersion === $toVersion) { // Hotfix: same version, just file updates $message = "Domain Monitor v{$toVersion} has been updated ({$migrationLabel})"; } else { diff --git a/app/Services/UpdateService.php b/app/Services/UpdateService.php index ebe1291..ca04697 100644 --- a/app/Services/UpdateService.php +++ b/app/Services/UpdateService.php @@ -125,6 +125,11 @@ class UpdateService // Cache commit info $this->settingModel->setValue('latest_remote_sha', $result['remote_sha'] ?? ''); $this->settingModel->setValue('commits_behind_count', count($commits)); + } else { + // No new commits — explicitly clear stale cache so the UI + // doesn't keep showing "update available" after a hotfix was applied. + $this->settingModel->setValue('commits_behind_count', '0'); + $this->settingModel->setValue('latest_remote_sha', ''); } } elseif ($channel === 'latest' && !$localSha) { $result['commit_tracking_unavailable'] = true; diff --git a/app/Views/settings/index.php b/app/Views/settings/index.php index 666750d..6dd2790 100644 --- a/app/Views/settings/index.php +++ b/app/Views/settings/index.php @@ -38,6 +38,12 @@ $currentVer = $appSettings['app_version'] ?? '0'; $latestVer = $updateSettings['latest_available_version'] ?? null; $updateChannel = $updateSettings['update_channel'] ?? 'stable'; $commitsBehind = (int)($updateSettings['commits_behind_count'] ?? 0); +$installedSha = $updateSettings['installed_commit_sha'] ?? ''; +$remoteSha = $updateSettings['latest_remote_sha'] ?? ''; +// If installed SHA matches remote SHA, there's no real hotfix — stale cache +if ($installedSha !== '' && $remoteSha !== '' && str_starts_with($installedSha, $remoteSha)) { + $commitsBehind = 0; +} if ($latestVer && version_compare($latestVer, $currentVer, '>')) { $cachedUpdateAvailable = true; $cachedUpdateData = [