From 2733508045ed948d94c66d44f6977e49d9b957d6 Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Sun, 21 Jun 2026 08:40:52 -0500 Subject: [PATCH] fix(install): delete empty-element rows and stale files in preflight Previous ALTER TABLE DEFAULT '' created orphaned extension rows with empty element, causing plugins to install to the group root. Preflight now deletes these rows and cleans stale services/src/language dirs. --- source/script.php | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/source/script.php b/source/script.php index 5b9d10f7..7e46ce24 100644 --- a/source/script.php +++ b/source/script.php @@ -54,10 +54,36 @@ class Pkg_MokosuiteclientInstallerScript $db->setQuery("ALTER TABLE " . $db->quoteName('#__extensions') . " MODIFY " . $db->quoteName('element') . " VARCHAR(100) NOT NULL"); $db->execute(); + + // Delete orphaned rows with empty element (created by the old DEFAULT '') + $db->setQuery("DELETE FROM " . $db->quoteName('#__extensions') + . " WHERE " . $db->quoteName('element') . " = ''"); + $db->execute(); + $deleted = $db->getAffectedRows(); + + if ($deleted > 0) + { + Log::add("Deleted {$deleted} orphaned extension row(s) with empty element", Log::INFO, 'mokosuiteclient'); + } + + // Remove stale plugin files that leaked to group root + $staleFiles = [ + JPATH_PLUGINS . '/system/services', + JPATH_PLUGINS . '/system/src', + JPATH_PLUGINS . '/system/language', + ]; + + foreach ($staleFiles as $stale) + { + if (is_dir($stale)) + { + $this->rmdirRecursive($stale); + } + } } catch (\Throwable $e) { - // Non-fatal — column may already be correct + // Non-fatal } }