From b8a282cdbc63d7b2330f0d86f97ee4654181512a Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Sat, 23 May 2026 23:20:16 -0500 Subject: [PATCH] fix: prevent pkg_pkg_ duplication in package zip names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit parseManifest() was falling back to the filename (pkg_mokowaas.xml → pkg_mokowaas) as the element, then typePrefix() prepended another pkg_. Now uses for packages and strips existing type prefixes from the element before prepending. Authored-by: Moko Consulting Co-Authored-By: Claude Opus 4.6 (1M context) --- cli/joomla_build.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cli/joomla_build.php b/cli/joomla_build.php index 17cbd88..36e0c4a 100644 --- a/cli/joomla_build.php +++ b/cli/joomla_build.php @@ -155,6 +155,14 @@ function parseManifest(string $file): array $element = (string) ($xml->element ?? ''); $group = (string) ($xml->attributes()->group ?? ''); + // For packages, prefer as the clean element (avoids pkg_pkg_ duplication) + if ($type === 'package' && $element === '') { + $packageName = (string) ($xml->packagename ?? ''); + if ($packageName !== '') { + $element = $packageName; + } + } + // Fallback element detection if ($element === '') { $element = (string) ($xml->attributes()->plugin ?? ''); } if ($element === '') { $element = (string) ($xml->attributes()->module ?? ''); } @@ -164,6 +172,10 @@ function parseManifest(string $file): array $element = strtolower(basename(dirname($file))); } } + + // Strip existing type prefix to prevent duplication (e.g. pkg_mokowaas → mokowaas) + $element = preg_replace('/^(pkg_|com_|mod_|plg_\w+_|tpl_|lib_)/', '', $element); + if ($name === '') { $name = $element; } return compact('name', 'type', 'element', 'group');