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