From 9b347dd13674fe7efda996c9482a370805f8ccd0 Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Thu, 18 Jun 2026 11:13:29 -0500 Subject: [PATCH] fix(backup): send error on failure, use staleDays for cutoff, consistent shape (#208) - Send explicit error status when backup data collection fails instead of omitting the key (so HQ can distinguish failure from not-installed) - Add status='ok' to not-installed return for consistent array shape - Use staleDays param instead of hardcoded 7-day cutoff in fallback query --- .../src/Extension/Backup.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/source/packages/plg_system_mokosuiteclient_backup/src/Extension/Backup.php b/source/packages/plg_system_mokosuiteclient_backup/src/Extension/Backup.php index b921da44..446b36c8 100644 --- a/source/packages/plg_system_mokosuiteclient_backup/src/Extension/Backup.php +++ b/source/packages/plg_system_mokosuiteclient_backup/src/Extension/Backup.php @@ -60,6 +60,14 @@ class Backup extends CMSPlugin implements SubscriberInterface catch (\Throwable $e) { Log::add('Backup bridge: ' . $e->getMessage(), Log::WARNING, 'mokosuiteclient'); + + // Send explicit error so HQ knows collection failed, + // rather than interpreting absence as "not installed" + $event->addResult('backup', [ + 'installed' => true, + 'status' => 'error', + 'message' => 'Failed to collect backup status', + ]); } } @@ -105,6 +113,7 @@ class Backup extends CMSPlugin implements SubscriberInterface { return [ 'installed' => false, + 'status' => 'ok', ]; } @@ -188,8 +197,7 @@ class Backup extends CMSPlugin implements SubscriberInterface ); $totalBackups = (int) $db->loadResult(); - // Recent completed backups (last 7 days) - $cutoff = date('Y-m-d H:i:s', strtotime('-7 days')); + $cutoff = date('Y-m-d H:i:s', strtotime("-{$staleDays} days")); $db->setQuery( $db->getQuery(true) ->select('COUNT(*)')