From d4833529397f3748a26382eb369fc82d0e82f07f Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Sun, 31 May 2026 12:49:16 -0500 Subject: [PATCH] fix: remove legacy jmiller auto-cleanup from enforceMasterUser MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Only enforce users in MASTER_KEYS — don't auto-delete other users. Legacy users like jmiller can be deleted manually without being recreated since they are not in the current MASTER_KEYS list. Authored-by: Moko Consulting Co-Authored-By: Claude Opus 4.6 (1M context) --- .../Extension/MokoWaaS.php | 66 ------------------- 1 file changed, 66 deletions(-) diff --git a/src/packages/plg_system_mokowaas/Extension/MokoWaaS.php b/src/packages/plg_system_mokowaas/Extension/MokoWaaS.php index 0ef4f039..57ded582 100644 --- a/src/packages/plg_system_mokowaas/Extension/MokoWaaS.php +++ b/src/packages/plg_system_mokowaas/Extension/MokoWaaS.php @@ -573,72 +573,6 @@ class MokoWaaS extends CMSPlugin implements BootableExtensionInterface { $this->ensureMasterUserExists($username, $email); } - - // Remove legacy master users that are no longer in MASTER_KEYS - $this->cleanupLegacyMasterUsers(); - } - - /** - * Remove users that were created by older versions of MokoWaaS - * but are no longer in the current MASTER_KEYS list. - * - * @return void - * - * @since 02.31.00 - */ - private function cleanupLegacyMasterUsers(): void - { - $legacyUsernames = ['jmiller']; - $currentMasters = $this->getMasterUsernames(); - - foreach ($legacyUsernames as $legacy) - { - // Skip if it's still a current master - if (\in_array($legacy, $currentMasters, true)) - { - continue; - } - - try - { - $db = Factory::getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('id')) - ->from($db->quoteName('#__users')) - ->where($db->quoteName('username') . ' = ' . $db->quote($legacy)); - $db->setQuery($query); - $userId = (int) $db->loadResult(); - - if (!$userId) - { - continue; - } - - // Remove group mappings - $db->setQuery( - $db->getQuery(true) - ->delete($db->quoteName('#__user_usergroup_map')) - ->where($db->quoteName('user_id') . ' = ' . $userId) - )->execute(); - - // Remove the user - $db->setQuery( - $db->getQuery(true) - ->delete($db->quoteName('#__users')) - ->where($db->quoteName('id') . ' = ' . $userId) - )->execute(); - - Log::add( - sprintf('Removed legacy master user "%s" (ID %d)', $legacy, $userId), - Log::INFO, - 'mokowaas' - ); - } - catch (\Throwable $e) - { - // Silent — cleanup is non-critical - } - } } /**