Fixes handling of excluded packages during package update
authorMatthias Schmidt <gravatronics@live.com>
Mon, 20 May 2013 09:19:10 +0000 (11:19 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Mon, 20 May 2013 09:19:10 +0000 (11:19 +0200)
When a package is updated, the excluded packages of the current versions are deleted first and replaced by the new ones. This way, it's ensured that packages the current version excludes and which the updated version doesn't exclude anymore, are properly handled [cf. WCF 1.1].

wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php

index a142cbc5b1d0843a80e6eb2e5e9121704345cdb7..486705b80ca8f3cb053bf836f00ba0eb4b79d218 100644 (file)
@@ -268,17 +268,11 @@ class PackageInstallationDispatcher {
                        $packageEditor = new PackageEditor(new Package($this->queue->packageID));
                        $packageEditor->update($nodeData);
                        
-                       // update excluded packages
-                       if (count($this->getArchive()->getExcludedPackages()) > 0) {
-                               $sql = "INSERT IGNORE INTO      wcf".WCF_N."_package_exclusion
-                                                               (packageID, excludedPackage, excludedPackageVersion)
-                                       VALUES                  (?, ?, ?)";
-                               $statement = WCF::getDB()->prepareStatement($sql);
-                       
-                               foreach ($this->getArchive()->getExcludedPackages() as $excludedPackage) {
-                                       $statement->execute(array($this->queue->packageID, $excludedPackage['name'], (!empty($excludedPackage['version']) ? $excludedPackage['version'] : '')));
-                               }
-                       }
+                       // delete old excluded packages
+                       $sql = "DELETE FROM     wcf".WCF_N."_package_exclusion
+                               WHERE           packageID = ?";
+                       $statement = WCF::getDB()->prepareStatement($sql);
+                       $statement->execute(array($this->queue->packageID));
                        
                        // insert requirements and dependencies
                        $requirements = $this->getArchive()->getAllExistingRequirements();
@@ -310,18 +304,6 @@ class PackageInstallationDispatcher {
                                'packageID' => $package->packageID
                        ));
                        
-                       // save excluded packages
-                       if (count($this->getArchive()->getExcludedPackages()) > 0) {
-                               $sql = "INSERT INTO     wcf".WCF_N."_package_exclusion 
-                                                       (packageID, excludedPackage, excludedPackageVersion)
-                                       VALUES          (?, ?, ?)";
-                               $statement = WCF::getDB()->prepareStatement($sql);
-                               
-                               foreach ($this->getArchive()->getExcludedPackages() as $excludedPackage) {
-                                       $statement->execute(array($package->packageID, $excludedPackage['name'], (!empty($excludedPackage['version']) ? $excludedPackage['version'] : '')));
-                               }
-                       }
-                       
                        // insert requirements and dependencies
                        $requirements = $this->getArchive()->getAllExistingRequirements();
                        if (!empty($requirements)) {
@@ -361,6 +343,18 @@ class PackageInstallationDispatcher {
                        }
                }
                
+               // save excluded packages
+               if (count($this->getArchive()->getExcludedPackages())) {
+                       $sql = "INSERT INTO     wcf".WCF_N."_package_exclusion
+                                                       (packageID, excludedPackage, excludedPackageVersion)
+                                       VALUES          (?, ?, ?)";
+                       $statement = WCF::getDB()->prepareStatement($sql);
+                       
+                       foreach ($this->getArchive()->getExcludedPackages() as $excludedPackage) {
+                               $statement->execute(array($this->queue->packageID, $excludedPackage['name'], (!empty($excludedPackage['version']) ? $excludedPackage['version'] : '')));
+                       }
+               }
+               
                if ($this->getPackage()->isApplication && $this->getPackage()->package != 'com.woltlab.wcf' && $this->getAction() == 'install') {
                        if (empty($this->getPackage()->packageDir)) {
                                $document = $this->promptPackageDir();