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>
This commit is contained in:
Christoph Wurst 2020-11-27 16:44:55 +01:00 committed by backportbot[bot]
parent 24fe3ee439
commit 0ae5c8dd3b
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 // Exclude all versions not compatible with the current version
try { try {
$versionParser = new VersionParser(); $versionParser = new VersionParser();
$version = $versionParser->getVersion($release['rawPlatformVersionSpec']); $serverVersion = $versionParser->getVersion($release['rawPlatformVersionSpec']);
$ncVersion = $this->getVersion(); $ncVersion = $this->getVersion();
$min = $version->getMinimumVersion(); $minServerVersion = $serverVersion->getMinimumVersion();
$max = $version->getMaximumVersion(); $maxServerVersion = $serverVersion->getMaximumVersion();
$minFulfilled = $this->compareVersion->isCompatible($ncVersion, $min, '>='); $minFulfilled = $this->compareVersion->isCompatible($ncVersion, $minServerVersion, '>=');
$maxFulfilled = $max !== '' && $maxFulfilled = $maxServerVersion !== '' &&
$this->compareVersion->isCompatible($ncVersion, $max, '<='); $this->compareVersion->isCompatible($ncVersion, $maxServerVersion, '<=');
if ($minFulfilled && ($this->ignoreMaxVersion || $maxFulfilled)) { $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; $releases[] = $release;
} }
} catch (\InvalidArgumentException $e) { } catch (\InvalidArgumentException $e) {