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)