aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/private/App/AppStore/Fetcher/AppFetcher.php18
-rw-r--r--lib/private/App/DependencyAnalyzer.php46
-rw-r--r--lib/private/Installer.php7
-rw-r--r--lib/private/legacy/app.php8
4 files changed, 45 insertions, 34 deletions
diff --git a/lib/private/App/AppStore/Fetcher/AppFetcher.php b/lib/private/App/AppStore/Fetcher/AppFetcher.php
index cf5839e4994..d8c505757c8 100644
--- a/lib/private/App/AppStore/Fetcher/AppFetcher.php
+++ b/lib/private/App/AppStore/Fetcher/AppFetcher.php
@@ -93,11 +93,8 @@ class AppFetcher extends Fetcher {
$version = $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 && $maxFulfilled) {
+ if ($minFulfilled) {
$releases[] = $release;
}
} catch (\InvalidArgumentException $e) {
@@ -113,20 +110,15 @@ class AppFetcher extends Fetcher {
}
usort($versions, 'version_compare');
$versions = array_reverse($versions);
- $compatible = false;
if(isset($versions[0])) {
$highestVersion = $versions[0];
foreach ($releases as $release) {
if ((string)$release['version'] === (string)$highestVersion) {
- $compatible = true;
$response['data'][$dataKey]['releases'] = [$release];
break;
}
}
}
- if(!$compatible) {
- unset($response['data'][$dataKey]);
- }
}
$response['data'] = array_values($response['data']);
@@ -134,13 +126,7 @@ class AppFetcher extends Fetcher {
}
private function setEndpoint() {
- $versionArray = explode('.', $this->getVersion());
- $this->endpointUrl = sprintf(
- 'https://apps.nextcloud.com/api/v1/platform/%d.%d.%d/apps.json',
- $versionArray[0],
- $versionArray[1],
- $versionArray[2]
- );
+ $this->endpointUrl = 'https://apps.nextcloud.com/api/v1/apps.json';
}
/**
diff --git a/lib/private/App/DependencyAnalyzer.php b/lib/private/App/DependencyAnalyzer.php
index 1e4d597dbc4..15a6a229476 100644
--- a/lib/private/App/DependencyAnalyzer.php
+++ b/lib/private/App/DependencyAnalyzer.php
@@ -29,6 +29,7 @@
namespace OC\App;
+use OCP\IConfig;
use OCP\IL10N;
class DependencyAnalyzer {
@@ -53,7 +54,7 @@ class DependencyAnalyzer {
* @param array $app
* @returns array of missing dependencies
*/
- public function analyze(array $app) {
+ public function analyze(array $app, bool $ignoreMax = false) {
$this->appInfo = $app;
if (isset($app['dependencies'])) {
$dependencies = $app['dependencies'];
@@ -67,10 +68,24 @@ class DependencyAnalyzer {
$this->analyzeCommands($dependencies),
$this->analyzeLibraries($dependencies),
$this->analyzeOS($dependencies),
- $this->analyzeOC($dependencies, $app)
+ $this->analyzeOC($dependencies, $app, $ignoreMax)
);
}
+ public function isMarkedCompatible(array $app): bool {
+ if (isset($app['dependencies'])) {
+ $dependencies = $app['dependencies'];
+ } else {
+ $dependencies = [];
+ }
+
+ $maxVersion = $this->getMaxVersion($dependencies, $app);
+ if ($maxVersion === null) {
+ return true;
+ }
+ return !$this->compareBigger($this->platform->getOcVersion(), $maxVersion);
+ }
+
/**
* Truncates both versions to the lowest common version, e.g.
* 5.1.2.3 and 5.1 will be turned into 5.1 and 5.1,
@@ -293,7 +308,7 @@ class DependencyAnalyzer {
* @param array $appInfo
* @return array
*/
- private function analyzeOC(array $dependencies, array $appInfo) {
+ private function analyzeOC(array $dependencies, array $appInfo, bool $ignoreMax) {
$missing = [];
$minVersion = null;
if (isset($dependencies['nextcloud']['@attributes']['min-version'])) {
@@ -305,21 +320,14 @@ class DependencyAnalyzer {
} elseif (isset($appInfo['require'])) {
$minVersion = $appInfo['require'];
}
- $maxVersion = null;
- if (isset($dependencies['nextcloud']['@attributes']['max-version'])) {
- $maxVersion = $dependencies['nextcloud']['@attributes']['max-version'];
- } elseif (isset($dependencies['owncloud']['@attributes']['max-version'])) {
- $maxVersion = $dependencies['owncloud']['@attributes']['max-version'];
- } elseif (isset($appInfo['requiremax'])) {
- $maxVersion = $appInfo['requiremax'];
- }
+ $maxVersion = $this->getMaxVersion($dependencies, $appInfo);
if (!is_null($minVersion)) {
if ($this->compareSmaller($this->platform->getOcVersion(), $minVersion)) {
$missing[] = (string)$this->l->t('Server version %s or higher is required.', [$this->toVisibleVersion($minVersion)]);
}
}
- if (!is_null($maxVersion)) {
+ if (!$ignoreMax && !is_null($maxVersion)) {
if ($this->compareBigger($this->platform->getOcVersion(), $maxVersion)) {
$missing[] = (string)$this->l->t('Server version %s or lower is required.', [$this->toVisibleVersion($maxVersion)]);
}
@@ -327,6 +335,20 @@ class DependencyAnalyzer {
return $missing;
}
+ private function getMaxVersion(array $dependencies, array $appInfo): ?string {
+ if (isset($dependencies['nextcloud']['@attributes']['max-version'])) {
+ return $dependencies['nextcloud']['@attributes']['max-version'];
+ }
+ if (isset($dependencies['owncloud']['@attributes']['max-version'])) {
+ return $dependencies['owncloud']['@attributes']['max-version'];
+ }
+ if (isset($appInfo['requiremax'])) {
+ return $appInfo['requiremax'];
+ }
+
+ return null;
+ }
+
/**
* Map the internal version number to the Nextcloud version
*
diff --git a/lib/private/Installer.php b/lib/private/Installer.php
index d58ccb36943..dc1110c0496 100644
--- a/lib/private/Installer.php
+++ b/lib/private/Installer.php
@@ -112,8 +112,11 @@ class Installer {
);
}
+ $ignoreMaxApps = $this->config->getSystemValue('app_install_overwrite', []);
+ $ignoreMax = in_array($appId, $ignoreMaxApps);
+
$version = implode('.', \OCP\Util::getVersion());
- if (!\OC_App::isAppCompatible($version, $info)) {
+ if (!\OC_App::isAppCompatible($version, $info, $ignoreMax)) {
throw new \Exception(
// TODO $l
$l->t('App "%s" cannot be installed because it is not compatible with this version of the server.',
@@ -123,7 +126,7 @@ class Installer {
}
// check for required dependencies
- \OC_App::checkAppDependencies($this->config, $l, $info);
+ \OC_App::checkAppDependencies($this->config, $l, $info, $ignoreMax);
\OC_App::registerAutoloading($appId, $basedir);
//install the database
diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php
index 9b4a83de349..9f51c022d6c 100644
--- a/lib/private/legacy/app.php
+++ b/lib/private/legacy/app.php
@@ -826,7 +826,7 @@ class OC_App {
*
* @return boolean true if compatible, otherwise false
*/
- public static function isAppCompatible(string $ocVersion, array $appInfo): bool {
+ public static function isAppCompatible(string $ocVersion, array $appInfo, bool $ignoreMax = false): bool {
$requireMin = '';
$requireMax = '';
if (isset($appInfo['dependencies']['nextcloud']['@attributes']['min-version'])) {
@@ -854,7 +854,7 @@ class OC_App {
return false;
}
- if (!empty($requireMax)
+ if (!$ignoreMax && !empty($requireMax)
&& version_compare(self::adjustVersionParts($ocVersion, $requireMax), $requireMax, '>')
) {
return false;
@@ -1090,9 +1090,9 @@ class OC_App {
* @param array $info
* @throws \Exception
*/
- public static function checkAppDependencies(\OCP\IConfig $config, \OCP\IL10N $l, array $info) {
+ public static function checkAppDependencies(\OCP\IConfig $config, \OCP\IL10N $l, array $info, bool $ignoreMax) {
$dependencyAnalyzer = new DependencyAnalyzer(new Platform($config), $l);
- $missing = $dependencyAnalyzer->analyze($info);
+ $missing = $dependencyAnalyzer->analyze($info, $ignoreMax);
if (!empty($missing)) {
$missingMsg = implode(PHP_EOL, $missing);
throw new \Exception(