diff options
-rw-r--r-- | lib/private/App/AppManager.php | 4 | ||||
-rw-r--r-- | lib/private/Installer.php | 2 | ||||
-rw-r--r-- | lib/private/legacy/app.php | 6 | ||||
-rw-r--r-- | lib/public/App/IAppManager.php | 4 | ||||
-rw-r--r-- | tests/lib/AppTest.php | 13 |
5 files changed, 6 insertions, 23 deletions
diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php index 0e921ba1b7f..ede1e5a7fa7 100644 --- a/lib/private/App/AppManager.php +++ b/lib/private/App/AppManager.php @@ -380,10 +380,10 @@ class AppManager implements IAppManager { return $data; } - public function getAppVersion(string $appId, bool $useCache = true) { + public function getAppVersion(string $appId, bool $useCache = true): string { if(!$useCache || !isset($this->appVersions[$appId])) { $appInfo = \OC::$server->getAppManager()->getAppInfo($appId); - $this->appVersions[$appId] = ($appInfo !== null) ? $appInfo['version'] : '0'; + $this->appVersions[$appId] = ($appInfo !== null && isset($appInfo['version'])) ? $appInfo['version'] : '0'; } return $this->appVersions[$appId]; } diff --git a/lib/private/Installer.php b/lib/private/Installer.php index f382a923401..8a8ece82077 100644 --- a/lib/private/Installer.php +++ b/lib/private/Installer.php @@ -112,7 +112,7 @@ class Installer { ); } - $version = \OCP\Util::getVersion(); + $version = implode('.', \OCP\Util::getVersion()); if (!\OC_App::isAppCompatible($version, $info)) { throw new \Exception( // TODO $l diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php index f04310041ac..40af10f36fc 100644 --- a/lib/private/legacy/app.php +++ b/lib/private/legacy/app.php @@ -856,7 +856,7 @@ class OC_App { * * @return boolean true if compatible, otherwise false */ - public static function isAppCompatible($ocVersion, $appInfo) { + public static function isAppCompatible(string $ocVersion, array $appInfo): bool { $requireMin = ''; $requireMax = ''; if (isset($appInfo['dependencies']['nextcloud']['@attributes']['min-version'])) { @@ -877,10 +877,6 @@ class OC_App { $requireMax = $appInfo['requiremax']; } - if (is_array($ocVersion)) { - $ocVersion = implode('.', $ocVersion); - } - if (!empty($requireMin) && version_compare(self::adjustVersionParts($ocVersion, $requireMin), $requireMin, '<') ) { diff --git a/lib/public/App/IAppManager.php b/lib/public/App/IAppManager.php index 0c087b61515..f0f14061e35 100644 --- a/lib/public/App/IAppManager.php +++ b/lib/public/App/IAppManager.php @@ -51,10 +51,10 @@ interface IAppManager { * * @param string $appId * @param bool $useCache - * @return mixed + * @return string * @since 14.0.0 */ - public function getAppVersion(string $appId, bool $useCache = true); + public function getAppVersion(string $appId, bool $useCache = true): string; /** * Check if an app is enabled for user diff --git a/tests/lib/AppTest.php b/tests/lib/AppTest.php index d10ad387599..04729303847 100644 --- a/tests/lib/AppTest.php +++ b/tests/lib/AppTest.php @@ -310,19 +310,6 @@ class AppTest extends \Test\TestCase { } /** - * Test that the isAppCompatible method also supports passing an array - * as $ocVersion - */ - public function testIsAppCompatibleWithArray() { - $ocVersion = array(6); - $appInfo = array( - 'requiremin' => '6', - 'requiremax' => '6', - ); - $this->assertTrue(\OC_App::isAppCompatible($ocVersion, $appInfo)); - } - - /** * Tests that the app order is correct */ public function testGetEnabledAppsIsSorted() { |