From e01167f6792809ca790a181287304e23c97fa8e8 Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Thu, 4 Jun 2026 10:41:26 -0500 Subject: [PATCH] fix: preflight ALTER for #__extensions.element default (strict mode) Joomla 6 + MySQL STRICT_TRANS_TABLES: the element column is NOT NULL with no default. Package installer creates placeholder rows before processing sub-extension manifests, causing INSERT failures. preflight() adds DEFAULT '' so the INSERT succeeds. Authored-by: Moko Consulting Co-Authored-By: Claude Opus 4.6 (1M context) --- src/script.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/script.php b/src/script.php index 4a15e66e..c75c8044 100644 --- a/src/script.php +++ b/src/script.php @@ -32,6 +32,28 @@ class Pkg_MokowaasInstallerScript * * @since 2.2.0 */ + /** + * Runs before package installation/update. + * + * Fixes MySQL strict mode incompatibility: #__extensions.element is NOT NULL + * with no default, causing INSERT failures when Joomla's package installer + * creates placeholder rows before processing sub-extension manifests. + */ + public function preflight($type, $parent) + { + try + { + $db = Factory::getDbo(); + $db->setQuery("ALTER TABLE " . $db->quoteName('#__extensions') + . " MODIFY " . $db->quoteName('element') . " VARCHAR(100) NOT NULL DEFAULT ''"); + $db->execute(); + } + catch (\Throwable $e) + { + // Non-fatal — column may already have a default + } + } + public function postflight($type, $parent) { // Remove legacy extensions and migrate settings before retiring