fix(install): use Joomla Installer API for plugin reinstall
Platform: moko-platform CI / Gate 2: Unit Tests (8.1) (push) Blocked by required conditions
Platform: moko-platform CI / Gate 2: Unit Tests (8.2) (push) Blocked by required conditions
Platform: moko-platform CI / Gate 2: Unit Tests (8.3) (push) Blocked by required conditions
Generic: Project CI / Tests (pull_request) Blocked by required conditions
Platform: moko-platform CI / Gate 3: Self-Health Check (push) Blocked by required conditions
Platform: moko-platform CI / Gate 4: Governance (push) Blocked by required conditions
Platform: moko-platform CI / Gate 5: Template Integrity (push) Blocked by required conditions
Platform: moko-platform CI / CI Summary (push) Blocked by required conditions
Joomla: Extension CI / Tests (PHP 8.2) (pull_request) Blocked by required conditions
Joomla: Extension CI / Tests (PHP 8.3) (pull_request) Blocked by required conditions
Joomla: Extension CI / PHPStan Analysis (pull_request) Blocked by required conditions
Joomla: Extension CI / Build RC Pre-Release (pull_request) Blocked by required conditions
Platform: moko-platform CI / Gate 2: Unit Tests (8.1) (pull_request) Blocked by required conditions
Platform: moko-platform CI / Gate 2: Unit Tests (8.2) (pull_request) Blocked by required conditions
Platform: moko-platform CI / Gate 2: Unit Tests (8.3) (pull_request) Blocked by required conditions
Platform: moko-platform CI / Gate 3: Self-Health Check (pull_request) Blocked by required conditions
Platform: moko-platform CI / Gate 4: Governance (pull_request) Blocked by required conditions
Platform: moko-platform CI / Gate 5: Template Integrity (pull_request) Blocked by required conditions
Platform: moko-platform CI / CI Summary (pull_request) Blocked by required conditions
Universal: PR Check / Build RC Package (pull_request) Blocked by required conditions
Universal: PR Check / Report Issues (pull_request) Blocked by required conditions
Generic: Repo Health / Scripts governance (pull_request) Blocked by required conditions
Generic: Repo Health / Repository health (pull_request) Blocked by required conditions
Generic: Repo Health / Report Issues (pull_request) Blocked by required conditions
Joomla: Extension CI / Release Readiness Check (pull_request) Failing after 14s
Universal: Auto Version Bump / Version Bump (push) Successful in 23s
Universal: Secret Scanning / Gitleaks Secret Scan (pull_request) Successful in 16s
Universal: PR Check / Branch Policy (pull_request) Successful in 2s
Universal: Pre-Release / Build Pre-Release (${{ inputs.stability || github.ref_name }}) (push) Successful in 20s
Universal: PR Check / Validate PR (pull_request) Failing after 7s
Platform: moko-platform CI / Gate 1: Code Quality (push) Failing after 52s
Generic: Repo Health / Access control (pull_request) Successful in 2s
Generic: Repo Health / Site Health (pull_request) Has been skipped
Generic: Project CI / Lint & Validate (pull_request) Successful in 56s
Joomla: Extension CI / Lint & Validate (pull_request) Failing after 58s
Platform: moko-platform CI / Gate 1: Code Quality (pull_request) Failing after 1m5s
Joomla: Metadata Validation / Validate Joomla Metadata (pull_request) Successful in 48s
Platform: moko-platform CI / Gate 2: Unit Tests (8.1) (push) Blocked by required conditions
Platform: moko-platform CI / Gate 2: Unit Tests (8.2) (push) Blocked by required conditions
Platform: moko-platform CI / Gate 2: Unit Tests (8.3) (push) Blocked by required conditions
Generic: Project CI / Tests (pull_request) Blocked by required conditions
Platform: moko-platform CI / Gate 3: Self-Health Check (push) Blocked by required conditions
Platform: moko-platform CI / Gate 4: Governance (push) Blocked by required conditions
Platform: moko-platform CI / Gate 5: Template Integrity (push) Blocked by required conditions
Platform: moko-platform CI / CI Summary (push) Blocked by required conditions
Joomla: Extension CI / Tests (PHP 8.2) (pull_request) Blocked by required conditions
Joomla: Extension CI / Tests (PHP 8.3) (pull_request) Blocked by required conditions
Joomla: Extension CI / PHPStan Analysis (pull_request) Blocked by required conditions
Joomla: Extension CI / Build RC Pre-Release (pull_request) Blocked by required conditions
Platform: moko-platform CI / Gate 2: Unit Tests (8.1) (pull_request) Blocked by required conditions
Platform: moko-platform CI / Gate 2: Unit Tests (8.2) (pull_request) Blocked by required conditions
Platform: moko-platform CI / Gate 2: Unit Tests (8.3) (pull_request) Blocked by required conditions
Platform: moko-platform CI / Gate 3: Self-Health Check (pull_request) Blocked by required conditions
Platform: moko-platform CI / Gate 4: Governance (pull_request) Blocked by required conditions
Platform: moko-platform CI / Gate 5: Template Integrity (pull_request) Blocked by required conditions
Platform: moko-platform CI / CI Summary (pull_request) Blocked by required conditions
Universal: PR Check / Build RC Package (pull_request) Blocked by required conditions
Universal: PR Check / Report Issues (pull_request) Blocked by required conditions
Generic: Repo Health / Scripts governance (pull_request) Blocked by required conditions
Generic: Repo Health / Repository health (pull_request) Blocked by required conditions
Generic: Repo Health / Report Issues (pull_request) Blocked by required conditions
Joomla: Extension CI / Release Readiness Check (pull_request) Failing after 14s
Universal: Auto Version Bump / Version Bump (push) Successful in 23s
Universal: Secret Scanning / Gitleaks Secret Scan (pull_request) Successful in 16s
Universal: PR Check / Branch Policy (pull_request) Successful in 2s
Universal: Pre-Release / Build Pre-Release (${{ inputs.stability || github.ref_name }}) (push) Successful in 20s
Universal: PR Check / Validate PR (pull_request) Failing after 7s
Platform: moko-platform CI / Gate 1: Code Quality (push) Failing after 52s
Generic: Repo Health / Access control (pull_request) Successful in 2s
Generic: Repo Health / Site Health (pull_request) Has been skipped
Generic: Project CI / Lint & Validate (pull_request) Successful in 56s
Joomla: Extension CI / Lint & Validate (pull_request) Failing after 58s
Platform: moko-platform CI / Gate 1: Code Quality (pull_request) Failing after 1m5s
Joomla: Metadata Validation / Validate Joomla Metadata (pull_request) Successful in 48s
Replace raw ZipArchive extract with Joomla\CMS\Installer\Installer::install() which properly handles namespace registration, extension record creation, and all internal bookkeeping. Removes manual INSERT from enablePlugin() since the Installer handles it correctly.
This commit is contained in:
+26
-52
@@ -520,47 +520,8 @@ class Pkg_MokosuiteclientInstallerScript
|
||||
->where($db->quoteName('element') . ' = ' . $db->quote($element))
|
||||
);
|
||||
|
||||
if ((int) $db->loadResult() > 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// No row exists — 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' => '{}',
|
||||
'custom_data' => '',
|
||||
'state' => 0,
|
||||
'ordering' => 0,
|
||||
'checked_out' => null,
|
||||
'checked_out_time' => null,
|
||||
];
|
||||
|
||||
if (!empty($namespace))
|
||||
{
|
||||
$row->namespace = $namespace;
|
||||
}
|
||||
|
||||
$db->insertObject('#__extensions', $row, 'extension_id');
|
||||
Log::add('Created extension record for plugin ' . $group . '/' . $element, Log::INFO, 'mokosuiteclient');
|
||||
}
|
||||
// No row exists — reinstallBrokenPlugins() will handle it via
|
||||
// Joomla's Installer which properly registers the namespace
|
||||
}
|
||||
catch (\Throwable $e)
|
||||
{
|
||||
@@ -679,8 +640,8 @@ class Pkg_MokosuiteclientInstallerScript
|
||||
|
||||
try
|
||||
{
|
||||
$installer = $this->installerParent->getParent();
|
||||
$sourceDir = $installer->getPath('source');
|
||||
$parentInstaller = $this->installerParent->getParent();
|
||||
$sourceDir = $parentInstaller->getPath('source');
|
||||
|
||||
if (empty($sourceDir) || !is_dir($sourceDir . '/packages'))
|
||||
{
|
||||
@@ -697,9 +658,6 @@ class Pkg_MokosuiteclientInstallerScript
|
||||
{
|
||||
foreach ($elements as $element)
|
||||
{
|
||||
$pluginDir = JPATH_PLUGINS . '/' . $group . '/' . $element;
|
||||
|
||||
// Always re-extract to ensure files are up to date
|
||||
$zipName = 'plg_' . $group . '_' . $element . '.zip';
|
||||
$zipPath = $sourceDir . '/packages/' . $zipName;
|
||||
|
||||
@@ -708,7 +666,17 @@ class Pkg_MokosuiteclientInstallerScript
|
||||
continue;
|
||||
}
|
||||
|
||||
// Extract the zip to the correct plugin directory
|
||||
// Use Joomla's Installer to properly install the plugin
|
||||
// This handles namespace registration, extension record, and file placement
|
||||
$tmpDir = Factory::getConfig()->get('tmp_path', sys_get_temp_dir()) . '/mokosuiteclient_' . $element;
|
||||
|
||||
if (is_dir($tmpDir))
|
||||
{
|
||||
$this->rmdirRecursive($tmpDir);
|
||||
}
|
||||
|
||||
@mkdir($tmpDir, 0755, true);
|
||||
|
||||
$zip = new \ZipArchive();
|
||||
|
||||
if ($zip->open($zipPath) !== true)
|
||||
@@ -716,14 +684,20 @@ class Pkg_MokosuiteclientInstallerScript
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_dir($pluginDir))
|
||||
$zip->extractTo($tmpDir);
|
||||
$zip->close();
|
||||
|
||||
$installer = new \Joomla\CMS\Installer\Installer();
|
||||
$installer->setOverwrite(true);
|
||||
$installer->setUpgrade(true);
|
||||
|
||||
if ($installer->install($tmpDir))
|
||||
{
|
||||
$this->rmdirRecursive($pluginDir);
|
||||
Log::add("Installed {$group}/{$element} via Joomla Installer", Log::INFO, 'mokosuiteclient');
|
||||
}
|
||||
|
||||
@mkdir($pluginDir, 0755, true);
|
||||
$zip->extractTo($pluginDir);
|
||||
$zip->close();
|
||||
// Clean up temp
|
||||
$this->rmdirRecursive($tmpDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user