Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No max version check for apps when using release channel git or daily #33360

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,7 @@ private static function printUpgradePage() {
$tmpl->assign('isAppsOnlyUpgrade', $isAppsOnlyUpgrade);

// get third party apps
$ocVersion = \OCP\Util::getVersion();
$tmpl->assign('appsToUpgrade', $appManager->getAppsNeedingUpgrade($ocVersion));
$tmpl->assign('appsToUpgrade', $appManager->getAppsNeedingUpgrade());
$tmpl->assign('productName', 'ownCloud'); // for now
$tmpl->assign('oldTheme', $oldTheme);
$tmpl->printPage();
Expand Down
33 changes: 8 additions & 25 deletions lib/private/App/AppManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ class AppManager implements IAppManager {
* @var string[][]
*/
private $appDirs = [];
/** @var Platform */
private $platform;

/**
* @param IUserSession $userSession
Expand All @@ -94,19 +96,22 @@ class AppManager implements IAppManager {
* @param ICacheFactory $memCacheFactory
* @param EventDispatcherInterface $dispatcher
* @param IConfig $config
* @param Platform $platform
*/
public function __construct(IUserSession $userSession = null,
IAppConfig $appConfig = null,
IGroupManager $groupManager = null,
ICacheFactory $memCacheFactory,
EventDispatcherInterface $dispatcher,
IConfig $config) {
IConfig $config,
Platform $platform) {
$this->userSession = $userSession;
$this->appConfig = $appConfig;
$this->groupManager = $groupManager;
$this->memCacheFactory = $memCacheFactory;
$this->dispatcher = $dispatcher;
$this->config = $config;
$this->platform = $platform;
}

/**
Expand Down Expand Up @@ -339,12 +344,11 @@ public function clearAppsCache() {
/**
* Returns a list of apps that need upgrade
*
* @param array $ocVersion ownCloud version as array of version components
* @return array list of app info from apps that need an upgrade
*
* @internal
*/
public function getAppsNeedingUpgrade($ocVersion) {
public function getAppsNeedingUpgrade() {
$appsToUpgrade = [];
$apps = $this->getInstalledApps();
foreach ($apps as $appId) {
Expand All @@ -353,7 +357,7 @@ public function getAppsNeedingUpgrade($ocVersion) {
if ($appDbVersion
&& isset($appInfo['version'])
&& \version_compare($appInfo['version'], $appDbVersion, '>')
&& \OC_App::isAppCompatible($ocVersion, $appInfo)
&& \OC_App::isAppCompatible($this->platform, $appInfo)
) {
$appsToUpgrade[] = $appInfo;
}
Expand Down Expand Up @@ -383,27 +387,6 @@ public function getAppInfo($appId) {
return $appInfo;
}

/**
* Returns a list of apps incompatible with the given version
*
* @param array $version ownCloud version as array of version components
*
* @return array list of app info from incompatible apps
*
* @internal
*/
public function getIncompatibleApps($version) {
$apps = $this->getInstalledApps();
$incompatibleApps = [];
foreach ($apps as $appId) {
$info = $this->getAppInfo($appId);
if (!\OC_App::isAppCompatible($version, $info)) {
$incompatibleApps[] = $info;
}
}
return $incompatibleApps;
}

/**
* @inheritdoc
*/
Expand Down
10 changes: 5 additions & 5 deletions lib/private/App/DependencyAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ private function analyzeDatabases(array $dependencies) {
return $this->getValue($db);
}, $supportedDatabases);
$currentDatabase = $this->platform->getDatabase();
if (!\in_array($currentDatabase, $supportedDatabases)) {
$missing[] = (string)$this->l->t('Following databases are supported: %s', \join(', ', $supportedDatabases));
if (!\in_array($currentDatabase, $supportedDatabases, true)) {
$missing[] = (string)$this->l->t('Following databases are supported: %s', \implode(', ', $supportedDatabases));
}
return $missing;
}
Expand Down Expand Up @@ -279,8 +279,8 @@ private function analyzeOS(array $dependencies) {
$oss = [$oss];
}
$currentOS = $this->platform->getOS();
if (!\in_array($currentOS, $oss)) {
$missing[] = (string)$this->l->t('Following platforms are supported: %s', \join(', ', $oss));
if (!\in_array($currentOS, $oss, true)) {
$missing[] = (string)$this->l->t('Following platforms are supported: %s', \implode(', ', $oss));
}
return $missing;
}
Expand Down Expand Up @@ -312,7 +312,7 @@ private function analyzeOC(array $dependencies, array $appInfo) {
$missing[] = (string)$this->l->t('ownCloud %s or higher is required.', $minVersion);
}
}
if ($maxVersion !== null) {
if ($maxVersion !== null && !\in_array($this->platform->getOcChannel(), ['git', 'daily'], true)) {
if ($this->compareBigger($this->platform->getOcVersion(), $maxVersion)) {
$missing[] = (string)$this->l->t('ownCloud %s or lower is required.', $maxVersion);
}
Expand Down
23 changes: 13 additions & 10 deletions lib/private/App/Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,29 @@ public function __construct(IConfig $config) {
/**
* @return string
*/
public function getPhpVersion() {
public function getPhpVersion(): string {
return \phpversion();
}

/**
* @return int
*/
public function getIntSize() {
public function getIntSize(): int {
return PHP_INT_SIZE;
}

/**
* @return string
*/
public function getOcVersion() {
public function getOcVersion(): string {
$v = \OCP\Util::getVersion();
return \join('.', $v);
return \implode('.', $v);
}

/**
* @return string
*/
public function getDatabase() {
public function getDatabase(): string {
$dbType = $this->config->getSystemValue('dbtype', 'sqlite');
if ($dbType === 'sqlite3') {
$dbType = 'sqlite';
Expand All @@ -80,22 +80,25 @@ public function getDatabase() {
/**
* @return string
*/
public function getOS() {
public function getOS(): string {
return \php_uname('s');
}

/**
* @param $command
* @return bool
*/
public function isCommandKnown($command) {
public function isCommandKnown($command): bool {
$path = \OC_Helper::findBinaryPath($command);
return ($path !== null);
}

public function getLibraryVersion($name) {
public function getLibraryVersion($name): ?string {
$repo = new PlatformRepository();
$lib = $repo->findLibrary($name);
return $lib;
return $repo->findLibrary($name);
}

public function getOcChannel(): string {
return \OCP\Util::getChannel();
}
}
3 changes: 2 additions & 1 deletion lib/private/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
namespace OC;

use Doctrine\DBAL\Exception\TableExistsException;
use OC\App\Platform;
use OC\DB\MigrationService;
use OC_App;
use OC_DB;
Expand Down Expand Up @@ -372,7 +373,7 @@ public static function checkAppsIntegrity($data, $extractDir, $path, $isShipped
}

// check if the app is compatible with this version of ownCloud
if (!OC_App::isAppCompatible(\OCP\Util::getVersion(), $info)) {
if (!OC_App::isAppCompatible(new Platform(\OC::$server->getConfig()), $info)) {
OC_Helper::rmdirr($extractDir);
throw new \Exception($l->t("App can't be installed because it is not compatible with this version of ownCloud"));
}
Expand Down
4 changes: 2 additions & 2 deletions lib/private/Repair/Apps.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;
use OC\App\Platform;
use OC\RepairException;
use OC_App;
use OCP\App\AppAlreadyInstalledException;
Expand Down Expand Up @@ -265,8 +266,7 @@ protected function getAppsToUpgrade() {
$appsToUpgrade[self::KEY_MISSING][] = $appId;
continue;
}
$version = Util::getVersion();
$key = (\OC_App::isAppCompatible($version, $info)) ? self::KEY_COMPATIBLE : self::KEY_INCOMPATIBLE;
$key = (\OC_App::isAppCompatible(new Platform($this->config), $info)) ? self::KEY_COMPATIBLE : self::KEY_INCOMPATIBLE;
$appsToUpgrade[$key][] = $appId;
}
return $appsToUpgrade;
Expand Down
4 changes: 3 additions & 1 deletion lib/private/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
namespace OC;

use bantu\IniGetWrapper\IniGetWrapper;
use OC\App\Platform;
use OC\AppFramework\Http\Request;
use OC\AppFramework\Db\Db;
use OC\AppFramework\Utility\TimeFactory;
Expand Down Expand Up @@ -594,7 +595,8 @@ public function __construct($webRoot, \OC\Config $config) {
$groupManager,
$c->getMemCacheFactory(),
$c->getEventDispatcher(),
$c->getConfig()
$c->getConfig(),
new Platform($c->getConfig())
);
});
$this->registerService('DateTimeZone', function (Server $c) {
Expand Down
Loading