From 361a58f8cddae1991cad769707e376b92eafdf51 Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Thu, 4 Jun 2026 17:50:52 -0500 Subject: [PATCH] fix: self-heal orphaned update records (extension_id=0) in postflight Joomla's update finder sometimes fails to link #__updates records to the installed extension. fixUpdateRecords() joins on element+type to set the correct extension_id. Authored-by: Moko Consulting Co-Authored-By: Claude Opus 4.6 (1M context) --- src/script.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/script.php b/src/script.php index 941b3683..85da88e6 100644 --- a/src/script.php +++ b/src/script.php @@ -101,6 +101,9 @@ class Pkg_MokowaasInstallerScript // Clean up stale/duplicate update sites $this->cleanupStaleUpdateSites(); + // Fix orphaned update records (extension_id=0) + $this->fixUpdateRecords(); + // Trigger heartbeat registration $this->sendHeartbeat(); @@ -555,6 +558,29 @@ class Pkg_MokowaasInstallerScript * * @since 02.31.00 */ + private function fixUpdateRecords(): void + { + try + { + $db = Factory::getDbo(); + + // Link orphaned #__updates records to the installed extension + $db->setQuery( + "UPDATE " . $db->quoteName('#__updates') . " u" + . " JOIN " . $db->quoteName('#__extensions') . " e" + . " ON u.element = e.element AND u.type = e.type" + . " SET u.extension_id = e.extension_id" + . " WHERE u.extension_id = 0" + . " AND u.element LIKE " . $db->quote('%mokowaas%') + ); + $db->execute(); + } + catch (\Throwable $e) + { + // Non-critical + } + } + private function cleanupStaleUpdateSites(): void { try