From a7f81e533b7c32f4836c21f6e0efef24c848bd6c Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Tue, 9 Jun 2026 11:57:47 -0500 Subject: [PATCH] fix: ensure modules stay published with correct positions on update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Module setup methods now update position and published state on reinstall/update instead of returning early when module exists. Also add mokosuite_dbip to plugin enable list. Modules: cpanel→top, menu→menu, cache→status --- source/script.php | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/source/script.php b/source/script.php index 42f89938..8ad33dcc 100644 --- a/source/script.php +++ b/source/script.php @@ -77,6 +77,7 @@ class Pkg_MokosuiteInstallerScript $this->enablePlugin('system', 'mokosuite_tenant'); $this->enablePlugin('system', 'mokosuite_devtools'); $this->enablePlugin('system', 'mokosuite_offline'); + $this->enablePlugin('system', 'mokosuite_dbip'); $this->enablePlugin('webservices', 'mokosuite'); $this->enablePlugin('task', 'mokosuitedemo'); $this->enablePlugin('task', 'mokosuitesync'); @@ -958,13 +959,22 @@ class Pkg_MokosuiteInstallerScript // Check if a module instance already exists in #__modules $query = $db->getQuery(true) - ->select('COUNT(*)') + ->select('id') ->from($db->quoteName('#__modules')) ->where($db->quoteName('module') . ' = ' . $db->quote('mod_mokosuite_cpanel')); $db->setQuery($query); + $existingId = (int) $db->loadResult(); - if ((int) $db->loadResult() > 0) + if ($existingId > 0) { + // Ensure it's published with correct position + $db->setQuery( + $db->getQuery(true) + ->update('#__modules') + ->set('published = 1') + ->set($db->quoteName('position') . ' = ' . $db->quote('top')) + ->where('id = ' . $existingId) + )->execute(); return; } @@ -1028,13 +1038,21 @@ class Pkg_MokosuiteInstallerScript // Check if module instance exists $db->setQuery( $db->getQuery(true) - ->select('COUNT(*)') + ->select('id') ->from($db->quoteName('#__modules')) ->where($db->quoteName('module') . ' = ' . $db->quote('mod_mokosuite_menu')) ); + $existingId = (int) $db->loadResult(); - if ((int) $db->loadResult() > 0) + if ($existingId > 0) { + $db->setQuery( + $db->getQuery(true) + ->update('#__modules') + ->set('published = 1') + ->set($db->quoteName('position') . ' = ' . $db->quote('menu')) + ->where('id = ' . $existingId) + )->execute(); return; } @@ -1091,13 +1109,21 @@ class Pkg_MokosuiteInstallerScript // Check if module instance exists $db->setQuery( $db->getQuery(true) - ->select('COUNT(*)') + ->select('id') ->from($db->quoteName('#__modules')) ->where($db->quoteName('module') . ' = ' . $db->quote('mod_mokosuite_cache')) ); + $existingId = (int) $db->loadResult(); - if ((int) $db->loadResult() > 0) + if ($existingId > 0) { + $db->setQuery( + $db->getQuery(true) + ->update('#__modules') + ->set('published = 1') + ->set($db->quoteName('position') . ' = ' . $db->quote('status')) + ->where('id = ' . $existingId) + )->execute(); return; }