From eb0b41101b73947c1f01e723f27710cb8c13d303 Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Sat, 13 Jun 2026 06:31:08 -0500 Subject: [PATCH] fix: add user-facing warnings for remaining silent failures - preflight_saveKey: warn user if license key could not be preserved - createDefaultScheduledTask: warn user to create task manually - migrateDefaultBackupDir: warn user to review profile settings - createBackupDirectory: warn if .htaccess protection file fails - boot(): widen catch to \Exception for consistency --- .../Extension/MokoSuiteBackupComponent.php | 2 +- source/script.php | 24 ++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/source/packages/com_mokosuitebackup/src/Extension/MokoSuiteBackupComponent.php b/source/packages/com_mokosuitebackup/src/Extension/MokoSuiteBackupComponent.php index 63329386..d9f4e012 100644 --- a/source/packages/com_mokosuitebackup/src/Extension/MokoSuiteBackupComponent.php +++ b/source/packages/com_mokosuitebackup/src/Extension/MokoSuiteBackupComponent.php @@ -45,7 +45,7 @@ class MokoSuiteBackupComponent extends MVCComponent . ' .main-nav a[href*="com_mokosuitebackup"][href*="view=backups"] .sidebar-item-title::before { content: "\f1c0"; }' . ' .main-nav a[href*="com_mokosuitebackup"][href*="view=profiles"] .sidebar-item-title::before { content: "\f013"; }' ); - } catch (\RuntimeException $e) { + } catch (\Exception $e) { error_log('MokoSuiteBackup: boot() CSS injection failed: ' . $e->getMessage()); } } diff --git a/source/script.php b/source/script.php index f4728626..bfbbe1cf 100644 --- a/source/script.php +++ b/source/script.php @@ -103,6 +103,11 @@ class Pkg_MokoSuiteBackupInstallerScript } } catch (\Exception $e) { error_log('MokoSuiteBackup: Could not save download key: ' . $e->getMessage()); + Factory::getApplication()->enqueueMessage( + 'MokoSuiteBackup could not preserve your download/license key before the update. ' + . 'Please verify your license key is still configured in System → Update Sites after this update completes.', + 'warning' + ); } } @@ -213,7 +218,14 @@ class Pkg_MokoSuiteBackupInstallerScript $htaccess = $backupDir . '/.htaccess'; if (!file_exists($htaccess)) { - file_put_contents($htaccess, "Order Deny,Allow\nDeny from all\n"); + if (file_put_contents($htaccess, "Order Deny,Allow\nDeny from all\n") === false) { + error_log('MokoSuiteBackup: Failed to write .htaccess to ' . $backupDir); + Factory::getApplication()->enqueueMessage( + 'MokoSuiteBackup created the backup directory but could not write an .htaccess file to protect it. ' + . 'Please manually create ' . htmlspecialchars($htaccess) . ' with "Deny from all" to prevent direct web access.', + 'warning' + ); + } } $indexHtml = $backupDir . '/index.html'; @@ -262,6 +274,11 @@ class Pkg_MokoSuiteBackupInstallerScript } } catch (\Exception $e) { error_log('MokoSuiteBackup: migrateDefaultBackupDir() failed: ' . $e->getMessage()); + Factory::getApplication()->enqueueMessage( + 'MokoSuiteBackup could not automatically migrate backup directory settings in your profiles. ' + . 'Please review your backup profiles and ensure the backup directory is set correctly.', + 'warning' + ); } } @@ -322,6 +339,11 @@ class Pkg_MokoSuiteBackupInstallerScript $db->insertObject('#__scheduler_tasks', $task); } catch (\Exception $e) { error_log('MokoSuiteBackup: createDefaultScheduledTask() failed: ' . $e->getMessage()); + Factory::getApplication()->enqueueMessage( + 'MokoSuiteBackup could not create the default scheduled backup task. ' + . 'Please create a scheduled task manually in System → Scheduled Tasks to enable automated backups.', + 'warning' + ); } }