diff --git a/source/script.php b/source/script.php index 241c05d3..b56a8491 100644 --- a/source/script.php +++ b/source/script.php @@ -39,8 +39,16 @@ class Pkg_MokowaasInstallerScript * with no default, causing INSERT failures when Joomla's package installer * creates placeholder rows before processing sub-extension manifests. */ + /** @var array Download keys saved before Joomla wipes update sites */ + private array $savedDownloadKeys = []; + public function preflight($type, $parent) { + // CRITICAL: backup download keys BEFORE Joomla's installer wipes update sites. + // Joomla deletes and recreates #__update_sites rows from the manifest + // between preflight and postflight, clearing extra_query (dlid). + $this->savedDownloadKeys = $this->backupDownloadKeys(); + try { $db = Factory::getDbo(); @@ -95,17 +103,14 @@ class Pkg_MokowaasInstallerScript // Mark MokoWaaS extensions as protected (prevents disable/uninstall at framework level) $this->protectExtensions(); - // Save download keys before any update site manipulation - $savedKeys = $this->backupDownloadKeys(); - // Migrate all Moko update server URLs to new format $this->migrateUpdateServerUrls(); // Clean up stale/duplicate update sites $this->cleanupStaleUpdateSites(); - // Restore download keys that were wiped by cleanup/migration - $this->restoreDownloadKeys($savedKeys); + // Restore download keys saved in preflight (before Joomla wiped them) + $this->restoreDownloadKeys($this->savedDownloadKeys); // Fix orphaned update records (extension_id=0) $this->fixUpdateRecords();