From 5e56f6869b2a1553e9b93a3cc2940078718e4bec Mon Sep 17 00:00:00 2001 From: Thomas Hunziker Date: Wed, 19 Nov 2025 16:23:54 +0100 Subject: [PATCH 1/2] Add oldFiles property for managing file updates Added a property to track old installed files for updates. This allows the parseFiles() method to automatically remove deleted files. Same code is already used in plugin and component adapter. --- .../src/Installer/Adapter/ModuleAdapter.php | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/libraries/src/Installer/Adapter/ModuleAdapter.php b/libraries/src/Installer/Adapter/ModuleAdapter.php index ef03cff37a975..c35a54b0ffc7d 100644 --- a/libraries/src/Installer/Adapter/ModuleAdapter.php +++ b/libraries/src/Installer/Adapter/ModuleAdapter.php @@ -48,6 +48,17 @@ class ModuleAdapter extends InstallerAdapter */ protected $scriptElement = null; + /** + * The list of current files that are installed and is read + * from the manifest on disk in the update area to handle doing a diff + * and deleting files that are in the old files list and not in the new + * files list. + * + * @var array + * @since 5.4 + * */ + protected $oldFiles = null; + /** * Method to check if the extension is already present in the database * @@ -91,7 +102,7 @@ protected function checkExistingExtension() protected function copyBaseFiles() { // Copy all necessary files - if ($this->parent->parseFiles($this->getManifest()->files, -1) === false) { + if ($this->parent->parseFiles($this->getManifest()->files, -1, $this->oldFiles) === false) { throw new \RuntimeException(Text::_('JLIB_INSTALLER_ABORT_MOD_COPY_FILES')); } @@ -528,6 +539,28 @@ protected function setupUninstall() $this->loadLanguage(($this->extension->client_id ? JPATH_ADMINISTRATOR : JPATH_SITE) . '/modules/' . $element); } + /** + * Method to setup the update routine for the adapter + * + * @return void + * + * @since 5.4 + */ + protected function setupUpdates() + { + // Create a new installer because findManifest sets stuff; side effects! + $tmpInstaller = new Installer(); + $tmpInstaller->setDatabase($this->getDatabase()); + + // Look in the extension root + $tmpInstaller->setPath('source', $this->parent->getPath('extension_root')); + + if ($tmpInstaller->findManifest()) { + $old_manifest = $tmpInstaller->getManifest(); + $this->oldFiles = $old_manifest->files; + } + } + /** * Method to store the extension to the database * From b339dfd1a8052d81d11bf45b7eb2570c9628336a Mon Sep 17 00:00:00 2001 From: Richard Fath Date: Thu, 20 Nov 2025 09:28:36 +0100 Subject: [PATCH 2/2] Use __DEPLOY_VERSION__ for since tag --- libraries/src/Installer/Adapter/ModuleAdapter.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/src/Installer/Adapter/ModuleAdapter.php b/libraries/src/Installer/Adapter/ModuleAdapter.php index c35a54b0ffc7d..1030f5ef844ea 100644 --- a/libraries/src/Installer/Adapter/ModuleAdapter.php +++ b/libraries/src/Installer/Adapter/ModuleAdapter.php @@ -55,7 +55,7 @@ class ModuleAdapter extends InstallerAdapter * files list. * * @var array - * @since 5.4 + * @since __DEPLOY_VERSION__ * */ protected $oldFiles = null; @@ -544,7 +544,7 @@ protected function setupUninstall() * * @return void * - * @since 5.4 + * @since __DEPLOY_VERSION__ */ protected function setupUpdates() {