From 9326e2d11aa76fd4eb78edf4ea378dda44c27000 Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Sat, 20 Jun 2026 18:34:13 -0500 Subject: [PATCH] fix(heartbeat): rotate RSA keys, fix backup bridge StatusHelper path - Replace broken RSA key pair (had Windows \r\n line endings in PEM) with fresh Unix-style keys that pass OpenSSL verify - Fix backup bridge: use correct Helper\BackupStatusHelper path and getStatusSummary() method per MokoSuite convention - Align fallback query output with StatusHelper return format (latest/totals structure instead of flat keys) --- .../mokosuiteclient.xml | 2 +- .../src/Extension/Backup.php | 64 ++++++++++++++----- .../mokosuiteclient_monitor.xml | 2 +- 3 files changed, 49 insertions(+), 19 deletions(-) diff --git a/source/packages/plg_system_mokosuiteclient/mokosuiteclient.xml b/source/packages/plg_system_mokosuiteclient/mokosuiteclient.xml index 9fe3df39..3554e27c 100644 --- a/source/packages/plg_system_mokosuiteclient/mokosuiteclient.xml +++ b/source/packages/plg_system_mokosuiteclient/mokosuiteclient.xml @@ -100,7 +100,7 @@ filter="url" /> 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 446b36c8..4d98d944 100644 --- a/source/packages/plg_system_mokosuiteclient_backup/src/Extension/Backup.php +++ b/source/packages/plg_system_mokosuiteclient_backup/src/Extension/Backup.php @@ -118,13 +118,11 @@ class Backup extends CMSPlugin implements SubscriberInterface } // Prefer MokoSuiteBackup's own helper (clean public API) - $helperClass = 'Joomla\\Component\\MokoSuiteBackup\\Administrator\\Utility\\BackupStatusHelper'; + $helperClass = 'Joomla\\Component\\MokoSuiteBackup\\Administrator\\Helper\\BackupStatusHelper'; if (class_exists($helperClass)) { - $staleDays = (int) $this->params->get('stale_days', 7); - - return $helperClass::getStatus($staleDays); + return $helperClass::getStatusSummary(); } // Fallback: direct table query for older MokoSuiteBackup versions @@ -244,20 +242,52 @@ class Backup extends CMSPlugin implements SubscriberInterface ? round($latest->total_size / 1048576) : null; + // Total counts (all time) + $db->setQuery( + $db->getQuery(true) + ->select('COUNT(*)') + ->from($db->quoteName('#__mokosuitebackup_records')) + ); + $allTime = (int) $db->loadResult(); + + $db->setQuery( + $db->getQuery(true) + ->select('COUNT(*)') + ->from($db->quoteName('#__mokosuitebackup_records')) + ->where($db->quoteName('status') . ' = ' . $db->quote('fail')) + ); + $allFailed = (int) $db->loadResult(); + + // Recent failures + $cutoff7d = date('Y-m-d H:i:s', strtotime('-7 days')); + $db->setQuery( + $db->getQuery(true) + ->select('COUNT(*)') + ->from($db->quoteName('#__mokosuitebackup_records')) + ->where($db->quoteName('status') . ' = ' . $db->quote('fail')) + ->where($db->quoteName('backupstart') . ' >= ' . $db->quote($cutoff7d)) + ); + $recentFailed = (int) $db->loadResult(); + return [ - 'installed' => true, - 'status' => $status, - 'last_backup' => $latest->backupstart, - 'last_status' => $latest->status, - 'last_size_mb' => $sizeMb, - 'days_since' => $daysSince, - 'backup_type' => $latest->backup_type, - 'origin' => $latest->origin, - 'total_backups' => $totalBackups, - 'recent_7d' => $recentBackups, - 'fail_count_7d' => $failCount7d, - 'files_exist' => (bool) $latest->filesexist, - 'description' => $latest->description, + 'installed' => true, + 'latest' => [ + 'status' => $latest->status, + 'backup_type' => $latest->backup_type ?? 'full', + 'description' => $latest->description ?? '', + 'backup_start' => $latest->backupstart, + 'backup_end' => $latest->backupend ?? null, + 'total_size' => (int) ($latest->total_size ?? 0), + 'origin' => $latest->origin ?? 'backend', + ], + 'totals' => [ + 'all_time' => $allTime, + 'all_success' => $totalBackups, + 'all_failed' => $allFailed, + 'recent_total' => $recentBackups + $recentFailed, + 'recent_success' => $recentBackups, + 'recent_failed' => $recentFailed, + ], ]; } } diff --git a/source/packages/plg_system_mokosuiteclient_monitor/mokosuiteclient_monitor.xml b/source/packages/plg_system_mokosuiteclient_monitor/mokosuiteclient_monitor.xml index 1a4a8d82..086d3f5e 100644 --- a/source/packages/plg_system_mokosuiteclient_monitor/mokosuiteclient_monitor.xml +++ b/source/packages/plg_system_mokosuiteclient_monitor/mokosuiteclient_monitor.xml @@ -44,7 +44,7 @@ filter="url" />