From: Marcel Werk Date: Fri, 15 Jul 2016 16:26:52 +0000 (+0200) Subject: Revert "Removed broken wildcard-support in fromversions" X-Git-Tag: 3.0.0_Beta_1~1119 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=5a095676d66cff346eb9f5f1e39f5bdf44ec5066;p=GitHub%2FWoltLab%2FWCF.git Revert "Removed broken wildcard-support in fromversions" This reverts commit 0cd9702924906fe8d4c39132f789d5f75c8806be. --- diff --git a/wcfsetup/install/files/lib/data/package/Package.class.php b/wcfsetup/install/files/lib/data/package/Package.class.php index c4eea656da..31bf7b21e2 100644 --- a/wcfsetup/install/files/lib/data/package/Package.class.php +++ b/wcfsetup/install/files/lib/data/package/Package.class.php @@ -282,13 +282,30 @@ class Package extends DatabaseObject { * Checks the version number of the installed package against the "fromversion" * number of the update. * + * The "fromversion" number may contain wildcards (asterisks) which means + * that the update covers the whole range of release numbers where the asterisk + * wildcards digits from 0 to 9. + * For example, if "fromversion" is "1.1.*" and this package updates to + * version 1.2.0, all releases from 1.1.0 to 1.1.9 may be updated using + * this package. + * * @param string $currentVersion * @param string $fromVersion * @return boolean */ public static function checkFromversion($currentVersion, $fromVersion) { - if (self::compareVersion($currentVersion, $fromVersion, '=')) { - return true; + if (mb_strpos($fromVersion, '*') !== false) { + // from version with wildcard + // use regular expression + $fromVersion = str_replace('\*', '.*', preg_quote($fromVersion, '!')); + if (preg_match('!^'.$fromVersion.'$!i', $currentVersion)) { + return true; + } + } + else { + if (self::compareVersion($currentVersion, $fromVersion, '=')) { + return true; + } } return false;