From df445186114b797d5d17fd24ebd85ee21f40b002 Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Sun, 7 Jun 2026 09:46:27 -0500 Subject: [PATCH] fix: skip all postflight actions on uninstall, add install warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Early return on uninstall to prevent license warning, menu sync, and default-dir check from running during package removal - Add warnDefaultBackupDir() — warns on install/update if any profile uses the default web-root backup directory - Add profile review reminder on fresh install with link to profiles view --- source/script.php | 54 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/source/script.php b/source/script.php index 0ceb68d..8c64545 100644 --- a/source/script.php +++ b/source/script.php @@ -213,12 +213,60 @@ class Pkg_MokoJoomBackupInstallerScript } } + if ($type === 'uninstall') { + return; + } + // Sync submenu icons in #__menu (Joomla doesn't update icons on upgrades) $this->syncMenuIcons(); - // Warn if no license key configured (skip on uninstall) - if ($type !== 'uninstall') { - $this->warnMissingLicenseKey(); + // Warn if no license key configured + $this->warnMissingLicenseKey(); + + // Warn if any profile still uses the default backup directory + $this->warnDefaultBackupDir(); + + // Remind user to review backup profile settings + if ($type === 'install') { + $profileUrl = Route::_('index.php?option=com_mokojoombackup&view=profiles'); + + Factory::getApplication()->enqueueMessage( + 'Review Your Backup Settings — ' + . 'A default backup profile has been created. Review the profile settings to configure ' + . 'backup type, schedule, storage location, and notifications. ' + . 'Review Profiles', + 'info' + ); + } + } + + private function warnDefaultBackupDir(): void + { + try { + $db = Factory::getDbo(); + $query = $db->getQuery(true) + ->select('COUNT(*)') + ->from($db->quoteName('#__mokojoombackup_profiles')) + ->where($db->quoteName('published') . ' = 1') + ->where('(' . $db->quoteName('backup_dir') . ' = ' . $db->quote('administrator/components/com_mokojoombackup/backups') + . ' OR ' . $db->quoteName('backup_dir') . ' = ' . $db->quote('[DEFAULT_DIR]') + . ' OR ' . $db->quoteName('backup_dir') . ' = ' . $db->quote('') + . ' OR ' . $db->quoteName('backup_dir') . ' IS NULL)'); + $db->setQuery($query); + + if ((int) $db->loadResult() > 0) { + $profileUrl = Route::_('index.php?option=com_mokojoombackup&view=profiles'); + + Factory::getApplication()->enqueueMessage( + 'Backup Directory Warning — ' + . 'One or more profiles store backups in the default directory inside the web root. ' + . 'For better security, configure a backup directory outside the web root. ' + . 'Edit Profiles', + 'warning' + ); + } + } catch (\Throwable $e) { + error_log('MokoJoomBackup: warnDefaultBackupDir() failed: ' . $e->getMessage()); } }