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) <noreply@anthropic.com>
This commit is contained in:
Jonathan Miller
2026-06-04 10:41:26 -05:00
parent 6d29e9a853
commit e01167f679
+22
View File
@@ -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