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