diff --git a/libraries/src/Installer/Adapter/ModuleAdapter.php b/libraries/src/Installer/Adapter/ModuleAdapter.php index ef03cff37a975..1030f5ef844ea 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 __DEPLOY_VERSION__ + * */ + 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 __DEPLOY_VERSION__ + */ + 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 *