fix(install): two-step plugin reinstall — extract files then create DB records
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 5s
Universal: PR Check / Branch Policy (pull_request) Successful in 1s
Universal: Auto Version Bump / Version Bump (push) Successful in 11s
Universal: Secret Scanning / Gitleaks Secret Scan (pull_request) Successful in 10s
Generic: Project CI / Lint & Validate (pull_request) Successful in 12s
Universal: PR Check / Validate PR (pull_request) Failing after 6s
Generic: Repo Health / Access control (pull_request) Successful in 1s
Generic: Repo Health / Site Health (pull_request) Has been skipped
Platform: moko-platform CI / Gate 1: Code Quality (push) Failing after 34s
Joomla: Extension CI / Lint & Validate (pull_request) Failing after 34s
Platform: moko-platform CI / Gate 1: Code Quality (pull_request) Failing after 39s
Joomla: Metadata Validation / Validate Joomla Metadata (pull_request) Successful in 35s
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 5s
Universal: PR Check / Branch Policy (pull_request) Successful in 1s
Universal: Auto Version Bump / Version Bump (push) Successful in 11s
Universal: Secret Scanning / Gitleaks Secret Scan (pull_request) Successful in 10s
Generic: Project CI / Lint & Validate (pull_request) Successful in 12s
Universal: PR Check / Validate PR (pull_request) Failing after 6s
Generic: Repo Health / Access control (pull_request) Successful in 1s
Generic: Repo Health / Site Health (pull_request) Has been skipped
Platform: moko-platform CI / Gate 1: Code Quality (push) Failing after 34s
Joomla: Extension CI / Lint & Validate (pull_request) Failing after 34s
Platform: moko-platform CI / Gate 1: Code Quality (pull_request) Failing after 39s
Joomla: Metadata Validation / Validate Joomla Metadata (pull_request) Successful in 35s
Step 1: Extract plugin zips to correct directories (always re-extract) Step 2: For each expected plugin with files but no DB record, INSERT with all required fields. Set namespace via separate UPDATE (handles Joomla versions without namespace column).
This commit is contained in:
+93
-22
@@ -666,17 +666,7 @@ class Pkg_MokosuiteclientInstallerScript
|
||||
continue;
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
// Extract to plugin dir
|
||||
$zip = new \ZipArchive();
|
||||
|
||||
if ($zip->open($zipPath) !== true)
|
||||
@@ -684,20 +674,101 @@ class Pkg_MokosuiteclientInstallerScript
|
||||
continue;
|
||||
}
|
||||
|
||||
$zip->extractTo($tmpDir);
|
||||
$zip->close();
|
||||
|
||||
$installer = new \Joomla\CMS\Installer\Installer();
|
||||
$installer->setOverwrite(true);
|
||||
$installer->setUpgrade(true);
|
||||
|
||||
if ($installer->install($tmpDir))
|
||||
if (is_dir($pluginDir))
|
||||
{
|
||||
Log::add("Installed {$group}/{$element} via Joomla Installer", Log::INFO, 'mokosuiteclient');
|
||||
$this->rmdirRecursive($pluginDir);
|
||||
}
|
||||
|
||||
// Clean up temp
|
||||
$this->rmdirRecursive($tmpDir);
|
||||
@mkdir($pluginDir, 0755, true);
|
||||
$zip->extractTo($pluginDir);
|
||||
$zip->close();
|
||||
}
|
||||
}
|
||||
|
||||
// Step 2: Create DB records for plugins that have files but no record
|
||||
$db = Factory::getDbo();
|
||||
|
||||
foreach ($expected as $group => $elements)
|
||||
{
|
||||
foreach ($elements as $element)
|
||||
{
|
||||
$pluginDir = JPATH_PLUGINS . '/' . $group . '/' . $element;
|
||||
$manifestFile = $pluginDir . '/' . $element . '.xml';
|
||||
|
||||
if (!is_file($manifestFile))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if record exists
|
||||
$db->setQuery(
|
||||
$db->getQuery(true)
|
||||
->select('COUNT(*)')
|
||||
->from($db->quoteName('#__extensions'))
|
||||
->where($db->quoteName('type') . ' = ' . $db->quote('plugin'))
|
||||
->where($db->quoteName('folder') . ' = ' . $db->quote($group))
|
||||
->where($db->quoteName('element') . ' = ' . $db->quote($element))
|
||||
);
|
||||
|
||||
if ((int) $db->loadResult() > 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Parse manifest for name and namespace
|
||||
$xml = @simplexml_load_file($manifestFile);
|
||||
$name = $xml ? (string) ($xml->name ?? '') : '';
|
||||
$namespace = $xml ? (string) ($xml->namespace ?? '') : '';
|
||||
$version = $xml ? (string) ($xml->version ?? '') : '';
|
||||
|
||||
if (empty($name))
|
||||
{
|
||||
$name = 'plg_' . $group . '_' . $element;
|
||||
}
|
||||
|
||||
// Build manifest cache
|
||||
$cache = json_encode([
|
||||
'name' => $name,
|
||||
'type' => 'plugin',
|
||||
'version' => $version,
|
||||
'group' => $group,
|
||||
]);
|
||||
|
||||
// INSERT with all required fields including namespace
|
||||
$columns = 'name, type, element, folder, client_id, enabled, access, protected, locked, params, manifest_cache, custom_data, state, ordering';
|
||||
$values = $db->quote($name) . ', '
|
||||
. $db->quote('plugin') . ', '
|
||||
. $db->quote($element) . ', '
|
||||
. $db->quote($group) . ', '
|
||||
. '0, 1, 1, 0, 0, '
|
||||
. $db->quote('{}') . ', '
|
||||
. $db->quote($cache) . ', '
|
||||
. $db->quote('') . ', 0, 0';
|
||||
|
||||
$sql = "INSERT INTO " . $db->quoteName('#__extensions')
|
||||
. " ({$columns}) VALUES ({$values})";
|
||||
$db->setQuery($sql)->execute();
|
||||
$newId = $db->insertid();
|
||||
|
||||
// Set namespace if column exists
|
||||
if (!empty($namespace))
|
||||
{
|
||||
try
|
||||
{
|
||||
$db->setQuery(
|
||||
$db->getQuery(true)
|
||||
->update($db->quoteName('#__extensions'))
|
||||
->set($db->quoteName('namespace') . ' = ' . $db->quote($namespace))
|
||||
->where($db->quoteName('extension_id') . ' = ' . (int) $newId)
|
||||
)->execute();
|
||||
}
|
||||
catch (\Throwable $e)
|
||||
{
|
||||
// namespace column may not exist in this Joomla version
|
||||
}
|
||||
}
|
||||
|
||||
Log::add("Created extension record for {$group}/{$element} (ID {$newId})", Log::INFO, 'mokosuiteclient');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user