fix(install): move empty-element cleanup to postflight, drop ALTER
Platform: moko-platform CI / Gate 2: Unit Tests (8.1) (push) Blocked by required conditions
Platform: moko-platform CI / Gate 2: Unit Tests (8.2) (push) Blocked by required conditions
Platform: moko-platform CI / Gate 2: Unit Tests (8.3) (push) Blocked by required conditions
Platform: moko-platform CI / Gate 3: Self-Health Check (push) Blocked by required conditions
Generic: Project CI / Tests (pull_request) Blocked by required conditions
Platform: moko-platform CI / Gate 4: Governance (push) Blocked by required conditions
Platform: moko-platform CI / Gate 5: Template Integrity (push) Blocked by required conditions
Platform: moko-platform CI / CI Summary (push) Blocked by required conditions
Joomla: Extension CI / Tests (PHP 8.2) (pull_request) Blocked by required conditions
Joomla: Extension CI / Tests (PHP 8.3) (pull_request) Blocked by required conditions
Joomla: Extension CI / PHPStan Analysis (pull_request) Blocked by required conditions
Joomla: Extension CI / Build RC Pre-Release (pull_request) Blocked by required conditions
Platform: moko-platform CI / Gate 2: Unit Tests (8.1) (pull_request) Blocked by required conditions
Platform: moko-platform CI / Gate 2: Unit Tests (8.2) (pull_request) Blocked by required conditions
Platform: moko-platform CI / Gate 2: Unit Tests (8.3) (pull_request) Blocked by required conditions
Platform: moko-platform CI / Gate 3: Self-Health Check (pull_request) Blocked by required conditions
Platform: moko-platform CI / Gate 4: Governance (pull_request) Blocked by required conditions
Platform: moko-platform CI / Gate 5: Template Integrity (pull_request) Blocked by required conditions
Platform: moko-platform CI / CI Summary (pull_request) Blocked by required conditions
Universal: PR Check / Build RC Package (pull_request) Blocked by required conditions
Universal: PR Check / Report Issues (pull_request) Blocked by required conditions
Generic: Repo Health / Scripts governance (pull_request) Blocked by required conditions
Generic: Repo Health / Repository health (pull_request) Blocked by required conditions
Generic: Repo Health / Report Issues (pull_request) Blocked by required conditions
Joomla: Extension CI / Release Readiness Check (pull_request) Failing after 5s
Universal: PR Check / Branch Policy (pull_request) Successful in 1s
Universal: Secret Scanning / Gitleaks Secret Scan (pull_request) Successful in 9s
Universal: PR Check / Validate PR (pull_request) Failing after 6s
Universal: Auto Version Bump / Version Bump (push) Successful in 12s
Generic: Repo Health / Access control (pull_request) Successful in 2s
Generic: Repo Health / Site Health (pull_request) Has been skipped
Platform: moko-platform CI / Gate 1: Code Quality (push) Failing after 37s
Universal: Pre-Release / Build Pre-Release (${{ inputs.stability || github.ref_name }}) (push) Successful in 21s
Joomla: Extension CI / Lint & Validate (pull_request) Failing after 37s
Generic: Project CI / Lint & Validate (pull_request) Successful in 38s
Platform: moko-platform CI / Gate 1: Code Quality (pull_request) Failing after 41s
Joomla: Metadata Validation / Validate Joomla Metadata (pull_request) Successful in 40s

The ALTER TABLE NOT NULL breaks Joomla's package installer on MySQL
strict mode. Instead, clean up empty-element rows and stale files in
postflight AFTER Joomla finishes installing sub-extensions.
This commit is contained in:
Jonathan Miller
2026-06-21 08:45:15 -05:00
parent 2348311528
commit e9bcee71be
+48 -39
View File
@@ -46,45 +46,6 @@ class Pkg_MokosuiteclientInstallerScript
{
$this->saveDownloadKey();
// Remove DEFAULT '' from element column — a previous version set this
// which caused Joomla to install plugin files to the group root
try
{
$db = Factory::getDbo();
$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
}
}
public function postflight($type, $parent)
@@ -136,6 +97,9 @@ class Pkg_MokosuiteclientInstallerScript
// Set up MokoSuiteClient guided tours and unpublish Joomla defaults
$this->setupGuidedTours();
// Clean up orphaned empty-element rows and stale files from old DEFAULT '' bug
$this->cleanupEmptyElements();
// Mark MokoSuiteClient extensions as protected (prevents disable/uninstall at framework level)
$this->protectExtensions();
@@ -543,6 +507,51 @@ class Pkg_MokosuiteclientInstallerScript
*
* @since 02.03.10
*/
private function cleanupEmptyElements(): void
{
try
{
$db = Factory::getDbo();
// Delete orphaned extension rows with empty element
$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');
Factory::getApplication()->enqueueMessage(
sprintf('Cleaned up %d orphaned extension record(s).', $deleted),
'message'
);
}
// Remove stale plugin files that leaked to group root
foreach (['services', 'src', 'language'] as $dir)
{
$path = JPATH_PLUGINS . '/system/' . $dir;
if (is_dir($path))
{
$this->rmdirRecursive($path);
Log::add("Removed stale directory: plugins/system/{$dir}", Log::INFO, 'mokosuiteclient');
}
}
// Remove stale XML manifests at group root
foreach (glob(JPATH_PLUGINS . '/system/mokosuiteclient_*.xml') ?: [] as $staleXml)
{
@unlink($staleXml);
}
}
catch (\Throwable $e)
{
Log::add('Empty element cleanup error: ' . $e->getMessage(), Log::WARNING, 'mokosuiteclient');
}
}
private function protectExtensions(): void
{
try