summaryrefslogtreecommitdiffstats
path: root/lib/private/App
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2020-11-27 16:44:55 +0100
committerChristoph Wurst <christoph@winzerhof-wurst.at>2020-12-04 16:52:31 +0100
commit24237f1a34b17dbf819403179577d6cc178de313 (patch)
treeadd69490ac2de5685854ec8976ef83fe2a96c02b /lib/private/App
parentf0862dcfaa0eee98a8cd5183f37cb92e96f5767a (diff)
downloadnextcloud-server-24237f1a34b17dbf819403179577d6cc178de313.tar.gz
nextcloud-server-24237f1a34b17dbf819403179577d6cc178de313.zip
Check php compatibility of app store app releases
Apps might increase the minimum php version requirement, in which case an update could break the app or even the whole instance. We must not install those releases, or better, don't even show them for update/installation. This extends the app fetcher code to filter out the releases that are not installable. The filter respects minimum and maximum requirements. E.g. apps that are still only released for php7.3 won't show up for php7.4 instances. This behavior is new but if an app lists an explicit version requirement, then we ought to repect that. Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib/private/App')
-rw-r--r--lib/private/App/AppStore/Fetcher/AppFetcher.php32
1 files changed, 25 insertions, 7 deletions
diff --git a/lib/private/App/AppStore/Fetcher/AppFetcher.php b/lib/private/App/AppStore/Fetcher/AppFetcher.php
index 21ec38ead30..4dc517879e8 100644
--- a/lib/private/App/AppStore/Fetcher/AppFetcher.php
+++ b/lib/private/App/AppStore/Fetcher/AppFetcher.php
@@ -101,14 +101,32 @@ class AppFetcher extends Fetcher {
// Exclude all versions not compatible with the current version
try {
$versionParser = new VersionParser();
- $version = $versionParser->getVersion($release['rawPlatformVersionSpec']);
+ $serverVersion = $versionParser->getVersion($release['rawPlatformVersionSpec']);
$ncVersion = $this->getVersion();
- $min = $version->getMinimumVersion();
- $max = $version->getMaximumVersion();
- $minFulfilled = $this->compareVersion->isCompatible($ncVersion, $min, '>=');
- $maxFulfilled = $max !== '' &&
- $this->compareVersion->isCompatible($ncVersion, $max, '<=');
- if ($minFulfilled && ($this->ignoreMaxVersion || $maxFulfilled)) {
+ $minServerVersion = $serverVersion->getMinimumVersion();
+ $maxServerVersion = $serverVersion->getMaximumVersion();
+ $minFulfilled = $this->compareVersion->isCompatible($ncVersion, $minServerVersion, '>=');
+ $maxFulfilled = $maxServerVersion !== '' &&
+ $this->compareVersion->isCompatible($ncVersion, $maxServerVersion, '<=');
+ $isPhpCompatible = true;
+ if (($release['rawPhpVersionSpec'] ?? '*') !== '*') {
+ $phpVersion = $versionParser->getVersion($release['rawPhpVersionSpec']);
+ $minPhpVersion = $phpVersion->getMinimumVersion();
+ $maxPhpVersion = $phpVersion->getMaximumVersion();
+ $minPhpFulfilled = $minPhpVersion === '' || $this->compareVersion->isCompatible(
+ PHP_VERSION,
+ $minPhpVersion,
+ '>='
+ );
+ $maxPhpFulfilled = $maxPhpVersion === '' || $this->compareVersion->isCompatible(
+ PHP_VERSION,
+ $maxPhpVersion,
+ '<='
+ );
+
+ $isPhpCompatible = $minPhpFulfilled && $maxPhpFulfilled;
+ }
+ if ($minFulfilled && ($this->ignoreMaxVersion || $maxFulfilled) && $isPhpCompatible) {
$releases[] = $release;
}
} catch (\InvalidArgumentException $e) {