fix: use release zip from updates.xml for mokocassiopeia install

The release zip is properly structured for Joomla installation.
Simplified extraction logic — release zips have templateDetails.xml
at root or one level deep. Added better error messages with the
failing URL for debugging.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-07 16:49:03 -05:00
parent 6094fef99e
commit acfecc383e
+19 -10
View File
@@ -262,7 +262,8 @@ class plgSystemMokoWaaSInstallerScript implements InstallerScriptInterface
if (empty($zipUrl))
{
Factory::getApplication()->enqueueMessage(
'MokoCassiopeia: could not resolve download URL.',
'MokoCassiopeia: could not resolve download URL '
. 'from updates.xml.',
'warning'
);
@@ -279,7 +280,7 @@ class plgSystemMokoWaaSInstallerScript implements InstallerScriptInterface
if ($data === false)
{
Factory::getApplication()->enqueueMessage(
'MokoCassiopeia not found and download failed.',
'MokoCassiopeia download failed: ' . $zipUrl,
'warning'
);
@@ -288,15 +289,15 @@ class plgSystemMokoWaaSInstallerScript implements InstallerScriptInterface
file_put_contents($tmpFile, $data);
// Extract the zip
// Extract the release zip
$archive = new \Joomla\Archive\Archive();
$archive->extract($tmpFile, $tmpDir);
// Find the extracted folder (may be nested)
// Release zips should have templateDetails.xml at root
// or one level deep
$installDir = $tmpDir;
$xmlFiles = glob($tmpDir . '/templateDetails.xml');
if (empty($xmlFiles))
if (!file_exists($tmpDir . '/templateDetails.xml'))
{
$xmlFiles = glob($tmpDir . '/*/templateDetails.xml');
@@ -304,17 +305,26 @@ class plgSystemMokoWaaSInstallerScript implements InstallerScriptInterface
{
$installDir = dirname($xmlFiles[0]);
}
else
{
Factory::getApplication()->enqueueMessage(
'MokoCassiopeia: templateDetails.xml not '
. 'found in archive.',
'warning'
);
return;
}
}
$installer = \Joomla\CMS\Installer\Installer::getInstance();
if ($installer->install($installDir))
{
// Lock after install
$this->ensureMokoCassiopeia();
Factory::getApplication()->enqueueMessage(
'MokoCassiopeia template installed and locked.',
'MokoCassiopeia installed and locked.',
'message'
);
}
@@ -329,8 +339,7 @@ class plgSystemMokoWaaSInstallerScript implements InstallerScriptInterface
catch (\Exception $e)
{
Factory::getApplication()->enqueueMessage(
'MokoCassiopeia install error: '
. $e->getMessage(),
'MokoCassiopeia error: ' . $e->getMessage(),
'warning'
);
}