Merge pull request #24698 from nextcloud/backport/24416/stable20

[stable20] Check php compatibility of app store app releases
This commit is contained in:
Roeland Jago Douma 2020-12-15 09:15:17 +01:00 committed by GitHub
commit f0c2807cac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 25 additions and 7 deletions

View File

@ -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) {