From: Alexander Ebert Date: Tue, 28 Jan 2014 19:56:53 +0000 (+0100) Subject: Fixed check for update version for manual uploads X-Git-Tag: 2.0.2_pl_1~4 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=49ec1439ee51fbfd5eafb84eefc1857d8791b8e8;p=GitHub%2FWoltLab%2FWCF.git Fixed check for update version for manual uploads --- diff --git a/wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php b/wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php index f1420ca1e2..272f24e92a 100755 --- a/wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php @@ -176,8 +176,7 @@ class PackageStartInstallForm extends AbstractForm { WCF::getSession()->checkPermissions(array('admin.system.package.canUpdatePackage')); $this->activeMenuItem = 'wcf.acp.menu.link.package'; - $this->archive->setPackage($this->package); - if (!$this->archive->isValidUpdate()) { + if (!$this->archive->isValidUpdate($this->package)) { throw new UserInputException($type, 'noValidUpdate'); } } diff --git a/wcfsetup/install/files/lib/system/package/PackageArchive.class.php b/wcfsetup/install/files/lib/system/package/PackageArchive.class.php index 032f701d4c..6b11ed97e1 100644 --- a/wcfsetup/install/files/lib/system/package/PackageArchive.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageArchive.class.php @@ -347,19 +347,7 @@ class PackageArchive { } if ($this->package != null) { - $validFromVersion = null; - foreach ($this->instructions['update'] as $fromVersion => $update) { - if (Package::checkFromversion($this->package->packageVersion, $fromVersion)) { - $validFromVersion = $fromVersion; - break; - } - } - if ($validFromVersion === null) { - $this->instructions['update'] = array(); - } - else { - $this->instructions['update'] = $this->instructions['update'][$validFromVersion]; - } + $this->filterUpdateInstructions(); } // set default values @@ -367,6 +355,26 @@ class PackageArchive { if (!isset($this->packageInfo['packageURL'])) $this->packageInfo['packageURL'] = ''; } + /** + * Filters update instructions. + */ + protected function filterUpdateInstructions() { + $validFromVersion = null; + foreach ($this->instructions['update'] as $fromVersion => $update) { + if (Package::checkFromversion($this->package->packageVersion, $fromVersion)) { + $validFromVersion = $fromVersion; + break; + } + } + + if ($validFromVersion === null) { + $this->instructions['update'] = array(); + } + else { + $this->instructions['update'] = $this->instructions['update'][$validFromVersion]; + } + } + /** * Downloads the package archive. * @@ -408,9 +416,17 @@ class PackageArchive { * Checks if the new package is compatible with * the package that is about to be updated. * - * @return boolean isValidUpdate + * @param \wcf\data\package\Package $package + * @return boolean isValidUpdate */ - public function isValidUpdate() { + public function isValidUpdate(Package $package = null) { + if ($this->package === null && $package !== null) { + $this->setPackage($package); + + // re-evaluate update data + $this->filterUpdateInstructions(); + } + // Check name of the installed package against the name of the update. Both must be identical. if ($this->packageInfo['name'] != $this->package->package) { return false; @@ -421,10 +437,12 @@ class PackageArchive { if (Package::compareVersion($this->packageInfo['version'], $this->package->packageVersion) != 1) { return false; } + // Check if the package provides an instructions block for the update from the installed package version if (empty($this->instructions['update'])) { return false; } + return true; }