Skip to content

Commit f0c2807

Browse files
authored
Merge pull request #24698 from nextcloud/backport/24416/stable20
[stable20] Check php compatibility of app store app releases
2 parents 2304f1e + 0ae5c8d commit f0c2807

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

lib/private/App/AppStore/Fetcher/AppFetcher.php

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,32 @@ protected function fetch($ETag, $content, $allowUnstable = false) {
101101
// Exclude all versions not compatible with the current version
102102
try {
103103
$versionParser = new VersionParser();
104-
$version = $versionParser->getVersion($release['rawPlatformVersionSpec']);
104+
$serverVersion = $versionParser->getVersion($release['rawPlatformVersionSpec']);
105105
$ncVersion = $this->getVersion();
106-
$min = $version->getMinimumVersion();
107-
$max = $version->getMaximumVersion();
108-
$minFulfilled = $this->compareVersion->isCompatible($ncVersion, $min, '>=');
109-
$maxFulfilled = $max !== '' &&
110-
$this->compareVersion->isCompatible($ncVersion, $max, '<=');
111-
if ($minFulfilled && ($this->ignoreMaxVersion || $maxFulfilled)) {
106+
$minServerVersion = $serverVersion->getMinimumVersion();
107+
$maxServerVersion = $serverVersion->getMaximumVersion();
108+
$minFulfilled = $this->compareVersion->isCompatible($ncVersion, $minServerVersion, '>=');
109+
$maxFulfilled = $maxServerVersion !== '' &&
110+
$this->compareVersion->isCompatible($ncVersion, $maxServerVersion, '<=');
111+
$isPhpCompatible = true;
112+
if (($release['rawPhpVersionSpec'] ?? '*') !== '*') {
113+
$phpVersion = $versionParser->getVersion($release['rawPhpVersionSpec']);
114+
$minPhpVersion = $phpVersion->getMinimumVersion();
115+
$maxPhpVersion = $phpVersion->getMaximumVersion();
116+
$minPhpFulfilled = $minPhpVersion === '' || $this->compareVersion->isCompatible(
117+
PHP_VERSION,
118+
$minPhpVersion,
119+
'>='
120+
);
121+
$maxPhpFulfilled = $maxPhpVersion === '' || $this->compareVersion->isCompatible(
122+
PHP_VERSION,
123+
$maxPhpVersion,
124+
'<='
125+
);
126+
127+
$isPhpCompatible = $minPhpFulfilled && $maxPhpFulfilled;
128+
}
129+
if ($minFulfilled && ($this->ignoreMaxVersion || $maxFulfilled) && $isPhpCompatible) {
112130
$releases[] = $release;
113131
}
114132
} catch (\InvalidArgumentException $e) {

0 commit comments

Comments
 (0)