diff --git a/source/script.php b/source/script.php index 35f28ec0..0ce971d0 100644 --- a/source/script.php +++ b/source/script.php @@ -818,152 +818,6 @@ class Pkg_MokosuiteclientInstallerScript } } - /** - * Rewrite all Moko Consulting update server URLs from the old - * raw/branch/main pattern to the new clean /updates.xml pattern. - * - * Old: https://git.mokoconsulting.tech/MokoConsulting/{repo}/raw/branch/main/updates.xml - * New: https://git.mokoconsulting.tech/MokoConsulting/{repo}/updates.xml - */ - private function migrateUpdateServerUrls(): void - { - try - { - $db = Factory::getDbo(); - - $db->setQuery( - "UPDATE " . $db->quoteName('#__update_sites') - . " SET " . $db->quoteName('location') . " = REPLACE(" - . $db->quoteName('location') . ", '/raw/branch/main/updates.xml', '/updates.xml')" - . " WHERE " . $db->quoteName('location') . " LIKE " . $db->quote('%mokoconsulting.tech%/raw/branch/main/updates.xml') - ); - $db->execute(); - $count = $db->getAffectedRows(); - - if ($count > 0) - { - Factory::getApplication()->enqueueMessage( - sprintf('Migrated %d Moko update server URL(s) to new format.', $count), - 'message' - ); - } - } - catch (\Throwable $e) - { - Log::add('Update server URL migration error: ' . $e->getMessage(), Log::WARNING, 'mokosuiteclient'); - } - } - - /** - * Remove stale and duplicate MokoSuiteClient update site entries. - * - * Keeps only the package-level update site pointing to the dynamic - * MokoGitea endpoint. Removes plugin-level entries, old static URLs, - * and orphaned #__updates rows tied to deleted update sites. - * - * @return void - * - * @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('%mokosuiteclient%') - ); - $db->execute(); - } - catch (\Throwable $e) - { - // Non-critical - } - } - - private function cleanupStaleUpdateSites(): void - { - try - { - $db = Factory::getDbo(); - $dynamicUrl = 'https://git.mokoconsulting.tech/MokoConsulting/MokoSuiteClient/updates.xml'; - - // Find MokoSuiteClient update sites (exclude MokoSuiteClientHQ and other Moko extensions) - $query = $db->getQuery(true) - ->select($db->quoteName(['update_site_id', 'location'])) - ->from($db->quoteName('#__update_sites')) - ->where('(' . $db->quoteName('name') . ' LIKE ' . $db->quote('%MokoSuiteClient%') - . ' OR ' . $db->quoteName('location') . ' LIKE ' . $db->quote('%MokoSuiteClient%') . ')') - ->where($db->quoteName('name') . ' NOT LIKE ' . $db->quote('%MokoSuiteClientHQ%')) - ->where($db->quoteName('location') . ' NOT LIKE ' . $db->quote('%MokoSuiteClientHQ%')); - $db->setQuery($query); - $sites = $db->loadObjectList(); - - $keepId = null; - $removeIds = []; - - foreach ($sites as $site) - { - if ($site->location === $dynamicUrl && $keepId === null) - { - $keepId = (int) $site->update_site_id; - } - else - { - $removeIds[] = (int) $site->update_site_id; - } - } - - if (empty($removeIds)) - { - return; - } - - $idList = implode(',', $removeIds); - - // Remove orphaned #__updates rows - $db->setQuery( - $db->getQuery(true) - ->delete($db->quoteName('#__updates')) - ->where($db->quoteName('update_site_id') . ' IN (' . $idList . ')') - )->execute(); - - // Remove link rows - $db->setQuery( - $db->getQuery(true) - ->delete($db->quoteName('#__update_sites_extensions')) - ->where($db->quoteName('update_site_id') . ' IN (' . $idList . ')') - )->execute(); - - // Remove stale update sites - $db->setQuery( - $db->getQuery(true) - ->delete($db->quoteName('#__update_sites')) - ->where($db->quoteName('update_site_id') . ' IN (' . $idList . ')') - )->execute(); - - $count = count($removeIds); - - if ($count > 0) - { - Factory::getApplication()->enqueueMessage( - sprintf('Cleaned up %d stale MokoSuiteClient update site(s).', $count), - 'message' - ); - } - } - catch (\Throwable $e) - { - Log::add('Error cleaning up stale update sites: ' . $e->getMessage(), Log::WARNING, 'jerror'); - } - } /** * Backup all non-empty extra_query values from update sites. diff --git a/updates.xml b/updates.xml new file mode 100644 index 00000000..15c911c4 --- /dev/null +++ b/updates.xml @@ -0,0 +1,20 @@ + + + + Package - MokoSuiteClient + pkg_mokosuiteclient + package + 02.52.04 + https://mokoconsulting.tech/support/mokosuiteclient + + https://git.mokoconsulting.tech/MokoConsulting/MokoSuiteClient/releases/download/stable/pkg_mokosuiteclient-02.52.04.zip + + + stable + + + 8.2 + site + MokoSuiteClient - Joomla client-facing tracker and identity layer for the MokoSuite platform. + +