From ca38121bb79a990b9a8a4048e3e5a2cee25b3058 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Fri, 5 Aug 2011 18:58:28 +0200 Subject: [PATCH] Fixed threw package update errors 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). --- .../install/files/lib/data/package/Package.class.php | 1 + .../files/lib/system/package/PackageArchive.class.php | 4 ++-- .../package/PackageInstallationDispatcher.class.php | 10 +++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/wcfsetup/install/files/lib/data/package/Package.class.php b/wcfsetup/install/files/lib/data/package/Package.class.php index bb31310639..ff4f7fdaaa 100644 --- a/wcfsetup/install/files/lib/data/package/Package.class.php +++ b/wcfsetup/install/files/lib/data/package/Package.class.php @@ -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; /** diff --git a/wcfsetup/install/files/lib/system/package/PackageArchive.class.php b/wcfsetup/install/files/lib/system/package/PackageArchive.class.php index 307026f821..f85f4d3ca6 100644 --- a/wcfsetup/install/files/lib/system/package/PackageArchive.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageArchive.class.php @@ -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; diff --git a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php index d7e7cc0983..504c4d1d65 100644 --- a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php @@ -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(); -- 2.20.1