From d1b18340eae3b548b5e9e3b39e9811e6c91ae716 Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Thu, 25 Jun 2026 09:48:42 -0500 Subject: [PATCH] fix: flush PSR-4 autoload cache after install for Joomla 6 compat Joomla 6 replaced the namespace column with a file-based autoload cache. Package installs can regenerate it before all sub-extensions are extracted, causing class-not-found errors (e.g. DB-IP plugin). Deleting the cache in postflight forces a clean rebuild. --- source/script.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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. *