fix: backup download keys in preflight, not postflight
Platform: moko-platform CI / Gate 2: Unit Tests (8.1) (push) Has been cancelled
Platform: moko-platform CI / Gate 2: Unit Tests (8.2) (push) Has been cancelled
Platform: moko-platform CI / Gate 2: Unit Tests (8.3) (push) Has been cancelled
Platform: moko-platform CI / Gate 3: Self-Health Check (push) Has been cancelled
Platform: moko-platform CI / Gate 4: Governance (push) Has been cancelled
Platform: moko-platform CI / Gate 5: Template Integrity (push) Has been cancelled
Platform: moko-platform CI / CI Summary (push) Has been cancelled
Generic: Repo Health / Scripts governance (push) Has been cancelled
Generic: Repo Health / Repository health (push) Has been cancelled
Generic: Repo Health / Report Issues (push) Has been cancelled
Generic: Repo Health / Site Health (push) Has been cancelled
Generic: Repo Health / Access control (push) Has been cancelled
Universal: Auto Version Bump / Version Bump (push) Has been cancelled
Platform: moko-platform CI / Gate 1: Code Quality (push) Has been cancelled

Joomla's package installer deletes and recreates update site rows
from the manifest BETWEEN preflight and postflight. By the time
postflight ran backupDownloadKeys(), the extra_query values were
already empty.

Moved the backup to preflight() via a class property. The restore
in postflight() now uses keys saved before Joomla touched them.

Authored-by: Moko Consulting
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jonathan Miller
2026-06-06 15:13:43 -05:00
parent 64a11706fd
commit 5ab496b399
+10 -5
View File
@@ -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();