Merge pull request 'fix: Resolve merge conflict markers in script.php' (#136) from fix/script-merge-conflicts into main

This commit was merged in pull request #136.
This commit is contained in:
2026-06-23 18:32:45 +00:00
-150
View File
@@ -114,7 +114,6 @@ class Pkg_MokoSuiteBackupInstallerScript
if (!empty($key)) {
$this->savedDownloadKey = $key;
}
<<<<<<< Updated upstream
} catch (\Exception $e) {
error_log('MokoSuiteBackup: Could not save download key: ' . $e->getMessage());
Factory::getApplication()->enqueueMessage(
@@ -122,10 +121,6 @@ class Pkg_MokoSuiteBackupInstallerScript
. 'Please verify your license key is still configured in System &rarr; Update Sites after this update completes.',
'warning'
);
=======
} catch (\Throwable $e) {
error_log('MokoSuiteBackup: Could not save download key: ' . $e->getMessage());
>>>>>>> Stashed changes
}
}
@@ -149,118 +144,16 @@ class Pkg_MokoSuiteBackupInstallerScript
}
if ($type === 'install') {
<<<<<<< Updated upstream
/* Enable all bundled plugins on fresh install */
$this->enableBundledPlugins();
=======
// Enable the system plugin automatically on fresh install
$db = Factory::getDbo();
$query = $db->getQuery(true)
->update($db->quoteName('#__extensions'))
->set($db->quoteName('enabled') . ' = 1')
->where($db->quoteName('type') . ' = ' . $db->quote('plugin'))
->where($db->quoteName('folder') . ' = ' . $db->quote('system'))
->where($db->quoteName('element') . ' = ' . $db->quote('mokosuitebackup'));
>>>>>>> Stashed changes
/* Create default backup directory in site root */
$this->createBackupDirectory();
<<<<<<< Updated upstream
/* Generate a random webcron secret word */
$this->generateWebcronSecret();
/* Create default scheduled task for backup automation */
=======
// Enable the quickicon plugin automatically
$query = $db->getQuery(true)
->update($db->quoteName('#__extensions'))
->set($db->quoteName('enabled') . ' = 1')
->where($db->quoteName('type') . ' = ' . $db->quote('plugin'))
->where($db->quoteName('folder') . ' = ' . $db->quote('quickicon'))
->where($db->quoteName('element') . ' = ' . $db->quote('mokosuitebackup'));
$db->setQuery($query);
$db->execute();
// Enable the task plugin automatically
$query = $db->getQuery(true)
->update($db->quoteName('#__extensions'))
->set($db->quoteName('enabled') . ' = 1')
->where($db->quoteName('type') . ' = ' . $db->quote('plugin'))
->where($db->quoteName('folder') . ' = ' . $db->quote('task'))
->where($db->quoteName('element') . ' = ' . $db->quote('mokosuitebackup'));
$db->setQuery($query);
$db->execute();
// Enable the webservices plugin automatically
$query = $db->getQuery(true)
->update($db->quoteName('#__extensions'))
->set($db->quoteName('enabled') . ' = 1')
->where($db->quoteName('type') . ' = ' . $db->quote('plugin'))
->where($db->quoteName('folder') . ' = ' . $db->quote('webservices'))
->where($db->quoteName('element') . ' = ' . $db->quote('mokosuitebackup'));
$db->setQuery($query);
$db->execute();
// Enable the console plugin automatically
$query = $db->getQuery(true)
->update($db->quoteName('#__extensions'))
->set($db->quoteName('enabled') . ' = 1')
->where($db->quoteName('type') . ' = ' . $db->quote('plugin'))
->where($db->quoteName('folder') . ' = ' . $db->quote('console'))
->where($db->quoteName('element') . ' = ' . $db->quote('mokosuitebackup'));
$db->setQuery($query);
$db->execute();
// Enable the content plugin automatically
$query = $db->getQuery(true)
->update($db->quoteName('#__extensions'))
->set($db->quoteName('enabled') . ' = 1')
->where($db->quoteName('type') . ' = ' . $db->quote('plugin'))
->where($db->quoteName('folder') . ' = ' . $db->quote('content'))
->where($db->quoteName('element') . ' = ' . $db->quote('mokosuitebackup'));
$db->setQuery($query);
$db->execute();
// Enable the actionlog plugin automatically
$query = $db->getQuery(true)
->update($db->quoteName('#__extensions'))
->set($db->quoteName('enabled') . ' = 1')
->where($db->quoteName('type') . ' = ' . $db->quote('plugin'))
->where($db->quoteName('folder') . ' = ' . $db->quote('actionlog'))
->where($db->quoteName('element') . ' = ' . $db->quote('mokosuitebackup'));
$db->setQuery($query);
$db->execute();
// Create and protect default backup directory
$backupDir = JPATH_ADMINISTRATOR . '/components/com_mokosuitebackup/backups';
if (!is_dir($backupDir)) {
mkdir($backupDir, 0755, true);
}
if (is_dir($backupDir)) {
$htaccess = $backupDir . '/.htaccess';
if (!is_file($htaccess)) {
file_put_contents($htaccess, "# Apache 2.4+\n<IfModule mod_authz_core.c>\n Require all denied\n</IfModule>\n# Apache 2.2\n<IfModule !mod_authz_core.c>\n Order deny,allow\n Deny from all\n</IfModule>\n");
}
$index = $backupDir . '/index.html';
if (!is_file($index)) {
file_put_contents($index, '<!DOCTYPE html><title></title>');
}
}
// Create default scheduled task — every 30 days, profile 1
>>>>>>> Stashed changes
$this->createDefaultScheduledTask();
}
@@ -430,20 +323,13 @@ class Pkg_MokoSuiteBackupInstallerScript
->select('COUNT(*)')
->from($db->quoteName('#__mokosuitebackup_profiles'))
->where($db->quoteName('published') . ' = 1')
<<<<<<< Updated upstream
->where('(' . $db->quoteName('backup_dir') . ' IN ('
. implode(',', array_map([$db, 'quote'], $oldDefaults))
. ') OR ' . $db->quoteName('backup_dir') . ' = ' . $db->quote('')
=======
->where('(' . $db->quoteName('backup_dir') . ' = ' . $db->quote('administrator/components/com_mokosuitebackup/backups')
. ' OR ' . $db->quoteName('backup_dir') . ' = ' . $db->quote('[DEFAULT_DIR]')
. ' OR ' . $db->quoteName('backup_dir') . ' = ' . $db->quote('')
>>>>>>> Stashed changes
. ' OR ' . $db->quoteName('backup_dir') . ' IS NULL)');
$db->setQuery($query);
if ((int) $db->loadResult() > 0) {
<<<<<<< Updated upstream
$update = $db->getQuery(true)
->update($db->quoteName('#__mokosuitebackup_profiles'))
->set($db->quoteName('backup_dir') . ' = ' . $db->quote('[DEFAULT_DIR]'))
@@ -453,9 +339,6 @@ class Pkg_MokoSuiteBackupInstallerScript
. ' OR ' . $db->quoteName('backup_dir') . ' IS NULL)');
$db->setQuery($update);
$db->execute();
=======
$profileUrl = Route::_('index.php?option=com_mokosuitebackup&view=profiles');
>>>>>>> Stashed changes
$migrated = $db->getAffectedRows();
@@ -463,7 +346,6 @@ class Pkg_MokoSuiteBackupInstallerScript
error_log('MokoSuiteBackup: Migrated ' . $migrated . ' profile(s) from legacy backup_dir to [DEFAULT_DIR]');
}
}
<<<<<<< Updated upstream
} catch (\Exception $e) {
error_log('MokoSuiteBackup: migrateDefaultBackupDir() failed: ' . $e->getMessage());
Factory::getApplication()->enqueueMessage(
@@ -471,10 +353,6 @@ class Pkg_MokoSuiteBackupInstallerScript
. 'Please review your backup profiles and ensure the backup directory is set correctly.',
'warning'
);
=======
} catch (\Throwable $e) {
error_log('MokoSuiteBackup: warnDefaultBackupDir() failed: ' . $e->getMessage());
>>>>>>> Stashed changes
}
}
@@ -483,11 +361,7 @@ class Pkg_MokoSuiteBackupInstallerScript
try {
$db = Factory::getDbo();
<<<<<<< Updated upstream
/* Check if a MokoSuiteBackup task already exists */
=======
// Check if a MokoSuiteBackup task already exists
>>>>>>> Stashed changes
$query = $db->getQuery(true)
->select('COUNT(*)')
->from($db->quoteName('#__scheduler_tasks'))
@@ -537,7 +411,6 @@ class Pkg_MokoSuiteBackupInstallerScript
];
$db->insertObject('#__scheduler_tasks', $task);
<<<<<<< Updated upstream
} catch (\Exception $e) {
error_log('MokoSuiteBackup: createDefaultScheduledTask() failed: ' . $e->getMessage());
Factory::getApplication()->enqueueMessage(
@@ -702,10 +575,6 @@ class Pkg_MokoSuiteBackupInstallerScript
. 'please reinstall the package.',
'warning'
);
=======
} catch (\Throwable $e) {
error_log('MokoSuiteBackup: createDefaultScheduledTask() failed: ' . $e->getMessage());
>>>>>>> Stashed changes
}
}
@@ -726,11 +595,7 @@ class Pkg_MokoSuiteBackupInstallerScript
->update($db->quoteName('#__menu'))
->set($db->quoteName('img') . ' = ' . $db->quote($icon))
->where($db->quoteName('client_id') . ' = 1')
<<<<<<< Updated upstream
->where($db->quoteName('link') . ' LIKE ' . $db->quote('index.php?option=com_mokosuitebackup%' . $linkFragment . '%'));
=======
->where($db->quoteName('link') . ' LIKE ' . $db->quote('%com_mokosuitebackup%' . $linkFragment . '%'));
>>>>>>> Stashed changes
$db->setQuery($query);
$db->execute();
}
@@ -743,17 +608,12 @@ class Pkg_MokoSuiteBackupInstallerScript
->where($db->quoteName('level') . ' = 1');
$db->setQuery($query);
$db->execute();
<<<<<<< Updated upstream
} catch (\Exception $e) {
error_log('MokoSuiteBackup: syncMenuIcons() failed: ' . $e->getMessage());
Factory::getApplication()->enqueueMessage(
'MokoSuiteBackup could not update sidebar menu icons. This is cosmetic and does not affect functionality.',
'notice'
);
=======
} catch (\Throwable $e) {
error_log('MokoSuiteBackup: syncMenuIcons() failed: ' . $e->getMessage());
>>>>>>> Stashed changes
}
}
@@ -791,7 +651,6 @@ class Pkg_MokoSuiteBackupInstallerScript
$db->setQuery($query);
$db->execute();
}
<<<<<<< Updated upstream
} catch (\Exception $e) {
error_log('MokoSuiteBackup: Could not restore download key: ' . $e->getMessage());
Factory::getApplication()->enqueueMessage(
@@ -799,10 +658,6 @@ class Pkg_MokoSuiteBackupInstallerScript
. 'Please re-enter it in the Update Sites configuration to continue receiving updates.',
'warning'
);
=======
} catch (\Throwable $e) {
error_log('MokoSuiteBackup: Could not restore download key: ' . $e->getMessage());
>>>>>>> Stashed changes
}
}
@@ -838,7 +693,6 @@ class Pkg_MokoSuiteBackupInstallerScript
'warning'
);
}
<<<<<<< Updated upstream
catch (\Exception $e) {
error_log('MokoSuiteBackup: License key check failed: ' . $e->getMessage());
Factory::getApplication()->enqueueMessage(
@@ -846,10 +700,6 @@ class Pkg_MokoSuiteBackupInstallerScript
. 'Please check System &rarr; Update Sites to ensure a valid license key is configured.',
'warning'
);
=======
catch (\Throwable $e) {
error_log('MokoSuiteBackup: License key check failed: ' . $e->getMessage());
>>>>>>> Stashed changes
}
}
}