From db4bf1c784f9d36e1bb8afbcc31e6caa08187683 Mon Sep 17 00:00:00 2001 From: Jonathan Miller <230051081+jmiller-moko@users.noreply.github.com> Date: Tue, 7 Apr 2026 16:26:40 -0500 Subject: [PATCH] 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) --- src/script.php | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/script.php b/src/script.php index 75f5c20..91cec48 100644 --- a/src/script.php +++ b/src/script.php @@ -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); + } } }