diff --git a/source/script.php b/source/script.php index 3b9b0bfb..35f28ec0 100644 --- a/source/script.php +++ b/source/script.php @@ -122,6 +122,9 @@ class Pkg_MokosuiteclientInstallerScript // Restore download key saved in preflight $this->restoreDownloadKey(); + // Flush PSR-4 autoload cache so Joomla 6+ picks up new/updated namespaces + $this->flushAutoloadCache(); + // Trigger heartbeat registration $this->sendHeartbeat(); @@ -1077,6 +1080,23 @@ class Pkg_MokosuiteclientInstallerScript } } + /** + * Delete the cached PSR-4 autoload map so Joomla rebuilds it from manifests. + * + * Joomla 6 replaced the #__extensions.namespace column with a file-based + * cache. Package installs sometimes regenerate it before all sub-extensions + * are extracted, leaving stale entries that cause class-not-found errors. + */ + private function flushAutoloadCache(): void + { + $cachePath = JPATH_ADMINISTRATOR . '/cache/autoload_psr4.php'; + + if (is_file($cachePath)) + { + @unlink($cachePath); + } + } + /** * Send heartbeat to the MokoSuiteClient monitoring receiver. *