From: Alexander Ebert Date: Mon, 5 Aug 2013 13:29:57 +0000 (+0200) Subject: Fixed selection of minor versions for updating X-Git-Tag: 2.0.0_Beta_7~62^2^2~3 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=755b25329c1b89093e0dce5d86f6833ae11f54aa;p=GitHub%2FWoltLab%2FWCF.git Fixed selection of minor versions for updating It is no longer possible to select a lower minor version, if a higher version of the same major release is available. That means you cannot select 4.0.0 Beta 5, if 4.0.0 Beta 6 is available. --- diff --git a/wcfsetup/install/files/lib/acp/page/PackageUpdatePage.class.php b/wcfsetup/install/files/lib/acp/page/PackageUpdatePage.class.php index 23cd7c79dd..a8e553b475 100644 --- a/wcfsetup/install/files/lib/acp/page/PackageUpdatePage.class.php +++ b/wcfsetup/install/files/lib/acp/page/PackageUpdatePage.class.php @@ -41,7 +41,7 @@ class PackageUpdatePage extends AbstractPage { public function readData() { parent::readData(); - $this->availableUpdates = PackageUpdateDispatcher::getInstance()->getAvailableUpdates(); + $this->availableUpdates = PackageUpdateDispatcher::getInstance()->getAvailableUpdates(true, true); } /** diff --git a/wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php b/wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php index 1af7d9cd05..82edd37cbd 100644 --- a/wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php @@ -521,9 +521,10 @@ class PackageUpdateDispatcher extends SingletonFactory { * Returns a list of available updates for installed packages. * * @param boolean $removeRequirements + * @param boolean $removeOlderMinorReleases * @return array */ - public function getAvailableUpdates($removeRequirements = true) { + public function getAvailableUpdates($removeRequirements = true, $removeOlderMinorReleases = false) { $updates = array(); // get update server data @@ -605,6 +606,33 @@ class PackageUpdateDispatcher extends SingletonFactory { } } + // remove older minor releases from list, e.g. only display 1.0.2, even if 1.0.1 is available + if ($removeOlderMinorReleases) { + foreach ($updates as &$updateData) { + $highestVersions = array(); + foreach ($updateData['versions'] as $versionNumber => $dummy) { + if (preg_match('~^(\d+\.\d+)\.~', $versionNumber, $matches)) { + $major = $matches[1]; + if (isset($highestVersions[$major])) { + if (version_compare($highestVersions[$major], $versionNumber, '<')) { + // version is newer, discard current version + unset($updateData['versions'][$highestVersions[$major]]); + $highestVersions[$major] = $versionNumber; + } + else { + // version is lower, discard + unset($updateData['versions'][$versionNumber]); + } + } + else { + $highestVersions[$major] = $versionNumber; + } + } + } + } + unset($updateData); + } + return $updates; }