Fixed threw package update errors
authorMatthias Schmidt <gravatronics@live.com>
Fri, 5 Aug 2011 16:58:28 +0000 (18:58 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Fri, 5 Aug 2011 16:58:28 +0000 (18:58 +0200)
Those three errors are: 1. After a package is updated, the package
version isn't updated. 2. Several pieces of code caused an error in
`PackageInstallationNodeBuilder::buildPluginNodes()` because
`PackageArchive::getUpdateInstructions()` returned an array with an
illegal structure that was created while building the update
instructions. 3. `use wcf\util\StringUtil;` was missing in `Package`
since the `StringUtil` is used in `Package::checkFromversion()` (just
used during updates, not during installations).

wcfsetup/install/files/lib/data/package/Package.class.php
wcfsetup/install/files/lib/system/package/PackageArchive.class.php
wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php

index bb31310639ecd88b0e064b3669874eb118d3be3c..ff4f7fdaaa8e1d6e34c18e6f28c2a72df95ed936 100644 (file)
@@ -5,6 +5,7 @@ use wcf\system\database\util\PreparedStatementConditionBuilder;
 use wcf\system\exception\SystemException;
 use wcf\system\io\File;
 use wcf\system\WCF;
+use wcf\util\StringUtil;
 use wcf\util\FileUtil;
 
 /**
index 307026f821c157173afc5cc0f9c01c7f55936a5d..f85f4d3ca65cc540c31ab3d524d75f2b27397215 100644 (file)
@@ -321,7 +321,7 @@ class PackageArchive {
                                $this->instructions['install'] = $instructionData;
                        }
                        else {
-                               $this->instructions['update'][$fromVersion][] = $instructionData;
+                               $this->instructions['update'][$fromVersion] = $instructionData;
                        }
                }
                
@@ -361,7 +361,7 @@ class PackageArchive {
                
                if ($this->package != null) {
                        $validFromVersion = null;
-                       foreach ($this->update as $fromVersion => $update) {
+                       foreach ($this->instructions['update'] as $fromVersion => $update) {
                                if (Package::checkFromversion($this->package->packageVersion, $fromVersion)) {
                                        $validFromVersion = $fromVersion;
                                        break;
index d7e7cc098387ac73c2d9927ecb741e190fd1679c..504c4d1d658d89a2a3416443a1cfcfc81fcd0515 100644 (file)
@@ -128,7 +128,7 @@ class PackageInstallationDispatcher {
         */
        public function getArchive() {
                if ($this->archive === null) {
-                       $this->archive = new PackageArchive($this->queue->archive);
+                       $this->archive = new PackageArchive($this->queue->archive, $this->getPackage());
                        
                        if (FileUtil::isURL($this->archive->getArchive())) {
                                // get return value and update entry in
@@ -553,6 +553,14 @@ class PackageInstallationDispatcher {
                // remove node data
                $this->nodeBuilder->purgeNodes();
                
+               // update package version
+               if ($this->action == 'update') {
+                       $packageEditor = new PackageEditor($this->getPackage());
+                       $packageEditor->update(array(
+                               'packageVersion' => $this->archive->getPackageInfo('version')
+                       ));
+               }
+               
                // return next queue within the same process no
                $queueID = $this->getNextQueue();