feat: unlock MokoCassiopeia + lock MokoOnyx during bridge migration
Some checks failed
Repo Health / Access control (push) Successful in 1s
Repo Health / Release configuration (push) Failing after 3s
Repo Health / Scripts governance (push) Successful in 3s
Repo Health / Repository health (push) Failing after 3s

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jonathan Miller
2026-04-21 17:05:57 -05:00
parent ca5614db73
commit 894597536e

View File

@@ -122,11 +122,14 @@ class Tpl_MokocassiopeiaInstallerScript implements InstallerScriptInterface
// 5. Redirect update server to MokoOnyx // 5. Redirect update server to MokoOnyx
$this->updateUpdateServer(); $this->updateUpdateServer();
// 6. Notify // 6. Unlock MokoCassiopeia (allow uninstall) + lock MokoOnyx (prevent accidental uninstall)
$this->updateExtensionLocks();
// 7. Notify
$app->enqueueMessage( $app->enqueueMessage(
'<strong>MokoOnyx has been installed as a replacement for MokoCassiopeia.</strong><br>' '<strong>MokoOnyx has been installed as a replacement for MokoCassiopeia.</strong><br>'
. 'Your template settings have been migrated. MokoOnyx is now your active site template.<br>' . 'Your template settings have been migrated. MokoOnyx is now your active site template.<br>'
. 'You can safely uninstall MokoCassiopeia from Extensions &rarr; Manage.', . 'MokoCassiopeia has been unlocked — you can uninstall it from Extensions &rarr; Manage.',
'success' 'success'
); );
@@ -362,6 +365,42 @@ class Tpl_MokocassiopeiaInstallerScript implements InstallerScriptInterface
} }
} }
private function updateExtensionLocks(): void
{
$db = Factory::getDbo();
// Unlock MokoCassiopeia — allow uninstall
try {
$query = $db->getQuery(true)
->update('#__extensions')
->set($db->quoteName('locked') . ' = 0')
->set($db->quoteName('protected') . ' = 0')
->where($db->quoteName('element') . ' = ' . $db->quote(self::OLD_NAME))
->where($db->quoteName('type') . ' = ' . $db->quote('template'));
$db->setQuery($query)->execute();
if ($db->getAffectedRows() > 0) {
$this->log('Bridge: unlocked MokoCassiopeia (can be uninstalled).');
}
} catch (\Throwable $e) {
$this->log('Bridge: failed to unlock MokoCassiopeia: ' . $e->getMessage(), 'warning');
}
// Lock MokoOnyx — prevent accidental uninstall
try {
$query = $db->getQuery(true)
->update('#__extensions')
->set($db->quoteName('locked') . ' = 1')
->where($db->quoteName('element') . ' = ' . $db->quote(self::NEW_NAME))
->where($db->quoteName('type') . ' = ' . $db->quote('template'));
$db->setQuery($query)->execute();
if ($db->getAffectedRows() > 0) {
$this->log('Bridge: locked MokoOnyx (protected from uninstall).');
}
} catch (\Throwable $e) {
$this->log('Bridge: failed to lock MokoOnyx: ' . $e->getMessage(), 'warning');
}
}
// ── Logging ──────────────────────────────────────────────────────── // ── Logging ────────────────────────────────────────────────────────
private function log(string $message, string $priority = 'info'): void private function log(string $message, string $priority = 'info'): void