Fix app version to be always string and neither array nor null
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
parent
edee243b27
commit
9dc3b04802
|
@ -380,10 +380,10 @@ class AppManager implements IAppManager {
|
||||||
return $data;
|
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])) {
|
if(!$useCache || !isset($this->appVersions[$appId])) {
|
||||||
$appInfo = \OC::$server->getAppManager()->getAppInfo($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];
|
return $this->appVersions[$appId];
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,7 @@ class Installer {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$version = \OCP\Util::getVersion();
|
$version = implode('.', \OCP\Util::getVersion());
|
||||||
if (!\OC_App::isAppCompatible($version, $info)) {
|
if (!\OC_App::isAppCompatible($version, $info)) {
|
||||||
throw new \Exception(
|
throw new \Exception(
|
||||||
// TODO $l
|
// TODO $l
|
||||||
|
|
|
@ -856,7 +856,7 @@ class OC_App {
|
||||||
*
|
*
|
||||||
* @return boolean true if compatible, otherwise false
|
* @return boolean true if compatible, otherwise false
|
||||||
*/
|
*/
|
||||||
public static function isAppCompatible($ocVersion, $appInfo) {
|
public static function isAppCompatible(string $ocVersion, array $appInfo): bool {
|
||||||
$requireMin = '';
|
$requireMin = '';
|
||||||
$requireMax = '';
|
$requireMax = '';
|
||||||
if (isset($appInfo['dependencies']['nextcloud']['@attributes']['min-version'])) {
|
if (isset($appInfo['dependencies']['nextcloud']['@attributes']['min-version'])) {
|
||||||
|
@ -877,10 +877,6 @@ class OC_App {
|
||||||
$requireMax = $appInfo['requiremax'];
|
$requireMax = $appInfo['requiremax'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($ocVersion)) {
|
|
||||||
$ocVersion = implode('.', $ocVersion);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($requireMin)
|
if (!empty($requireMin)
|
||||||
&& version_compare(self::adjustVersionParts($ocVersion, $requireMin), $requireMin, '<')
|
&& version_compare(self::adjustVersionParts($ocVersion, $requireMin), $requireMin, '<')
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -51,10 +51,10 @@ interface IAppManager {
|
||||||
*
|
*
|
||||||
* @param string $appId
|
* @param string $appId
|
||||||
* @param bool $useCache
|
* @param bool $useCache
|
||||||
* @return mixed
|
* @return string
|
||||||
* @since 14.0.0
|
* @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
|
* Check if an app is enabled for user
|
||||||
|
|
|
@ -309,19 +309,6 @@ class AppTest extends \Test\TestCase {
|
||||||
$this->assertEquals($expectedResult, \OC_App::isAppCompatible($ocVersion, $appInfo));
|
$this->assertEquals($expectedResult, \OC_App::isAppCompatible($ocVersion, $appInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
* Tests that the app order is correct
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue