From ac0c4cab817400da6887f4e9e3f1a7913f650116 Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Sun, 21 Jun 2026 10:01:21 -0500 Subject: [PATCH] fix(install): create extension records for plugins missing from DB enablePlugin now INSERTs a new extension row from the manifest XML when no row exists (neither by element nor by empty element). This handles the case where cleanupEmptyElements deleted the orphan rows but the files were reinstalled from the package zip. --- source/script.php | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/source/script.php b/source/script.php index d920a019..f4312889 100644 --- a/source/script.php +++ b/source/script.php @@ -507,6 +507,41 @@ class Pkg_MokosuiteclientInstallerScript if ($db->getAffectedRows() > 0) { Log::add('Fixed empty element for plugin ' . $group . '/' . $element, Log::NOTICE, 'mokosuiteclient'); + + return; + } + + // No row exists at all — create one from the manifest XML on disk + $manifestFile = $pluginDir . '/' . $element . '.xml'; + + if (is_file($manifestFile)) + { + $xml = @simplexml_load_file($manifestFile); + $name = $xml ? (string) ($xml->name ?? $manifestName) : $manifestName; + $namespace = $xml ? (string) ($xml->namespace ?? '') : ''; + + $row = (object) [ + 'name' => $name, + 'type' => 'plugin', + 'element' => $element, + 'folder' => $group, + 'client_id' => 0, + 'enabled' => 1, + 'access' => 1, + 'protected' => 0, + 'locked' => 0, + 'params' => '{}', + 'manifest_cache' => '{}', + 'state' => 0, + ]; + + if (!empty($namespace)) + { + $row->namespace = $namespace; + } + + $db->insertObject('#__extensions', $row, 'extension_id'); + Log::add('Created extension record for plugin ' . $group . '/' . $element, Log::INFO, 'mokosuiteclient'); } } catch (\Throwable $e)