fix: extract mokocassiopeia zip before installing

Joomla Installer::install() expects a directory path, not a zip file.
Now extracts the zip to a temp folder, finds the templateDetails.xml,
and passes the correct directory to the installer.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-07 16:26:40 -05:00
parent 19214dd672
commit db4bf1c784
+28 -3
View File
@@ -252,9 +252,10 @@ class plgSystemMokoWaaSInstallerScript implements InstallerScriptInterface
}
// Template not installed — try to install from GitHub
$zipUrl = 'https://github.com/mokoconsulting-tech/MokoCassiopeia'
$zipUrl = 'https://github.com/mokoconsulting-tech/MokoCassiopeia'
. '/releases/latest/download/MokoCassiopeia.zip';
$tmpFile = JPATH_ROOT . '/tmp/mokocassiopeia.zip';
$tmpDir = JPATH_ROOT . '/tmp/mokocassiopeia';
try
{
@@ -272,9 +273,27 @@ class plgSystemMokoWaaSInstallerScript implements InstallerScriptInterface
file_put_contents($tmpFile, $data);
// Extract the zip
$archive = new \Joomla\Archive\Archive();
$archive->extract($tmpFile, $tmpDir);
// Find the extracted folder (may be nested)
$installDir = $tmpDir;
$xmlFiles = glob($tmpDir . '/templateDetails.xml');
if (empty($xmlFiles))
{
$xmlFiles = glob($tmpDir . '/*/templateDetails.xml');
if (!empty($xmlFiles))
{
$installDir = dirname($xmlFiles[0]);
}
}
$installer = \Joomla\CMS\Installer\Installer::getInstance();
if ($installer->install($tmpFile))
if ($installer->install($installDir))
{
// Lock after install
$this->ensureMokoCassiopeia();
@@ -295,13 +314,19 @@ class plgSystemMokoWaaSInstallerScript implements InstallerScriptInterface
catch (\Exception $e)
{
Factory::getApplication()->enqueueMessage(
'MokoCassiopeia install error: ' . $e->getMessage(),
'MokoCassiopeia install error: '
. $e->getMessage(),
'warning'
);
}
finally
{
@unlink($tmpFile);
if (is_dir($tmpDir))
{
Folder::delete($tmpDir);
}
}
}