diff --git a/lib/private/Installer.php b/lib/private/Installer.php index a3ceca83b64..7182b33e79d 100644 --- a/lib/private/Installer.php +++ b/lib/private/Installer.php @@ -99,7 +99,7 @@ class Installer { * @param bool $allowUnstable Allow unstable releases */ public function updateAppstoreApp(string $appId, bool $allowUnstable = false): bool { - if ($this->isUpdateAvailable($appId, $allowUnstable)) { + if ($this->isUpdateAvailable($appId, $allowUnstable) !== false) { try { $this->downloadApp($appId, $allowUnstable); } catch (\Exception $e) { @@ -108,7 +108,7 @@ class Installer { ]); return false; } - return OC_App::updateApp($appId); + return $this->appManager->upgradeApp($appId); } return false; @@ -475,8 +475,7 @@ class Installer { $this->downloadApp($appId); } $this->installApp($appId); - $app = new OC_App(); - $app->enable($appId); + $this->appManager->enableApp($appId); } $bundles = json_decode($this->config->getAppValue('core', 'installed.bundles', json_encode([])), true); $bundles[] = $bundle->getIdentifier(); diff --git a/lib/private/Updater.php b/lib/private/Updater.php index fdbfa9690e5..da7b52e5493 100644 --- a/lib/private/Updater.php +++ b/lib/private/Updater.php @@ -389,12 +389,11 @@ class Updater extends BasicEmitter { } $this->emit('\OC\Updater', 'checkAppStoreApp', [$app]); - if (!empty($previousEnableStates)) { - $ocApp = new \OC_App(); + if (isset($previousEnableStates[$app])) { if (!empty($previousEnableStates[$app]) && is_array($previousEnableStates[$app])) { - $ocApp->enable($app, $previousEnableStates[$app]); - } else { - $ocApp->enable($app); + $this->appManager->enableAppForGroups($app, $previousEnableStates[$app]); + } elseif ($previousEnableStates[$app] === 'yes') { + $this->appManager->enableApp($app); } } } catch (\Exception $ex) { diff --git a/lib/private/legacy/OC_App.php b/lib/private/legacy/OC_App.php index 6e9c1b8265c..71271eda6f2 100644 --- a/lib/private/legacy/OC_App.php +++ b/lib/private/legacy/OC_App.php @@ -201,6 +201,7 @@ class OC_App { * @param array $groups (optional) when set, only these groups will have access to the app * @throws \Exception * @return void + * @deprecated 32.0.0 Use the installer and the app manager instead * * This function set an app as enabled in appconfig. */ @@ -538,6 +539,9 @@ class OC_App { return $appList; } + /** + * @deprecated 32.0.0 Use IAppManager::isUpgradeRequired instead + */ public static function shouldUpgrade(string $app): bool { return Server::get(\OCP\App\IAppManager::class)->isUpgradeRequired($app); } @@ -557,6 +561,7 @@ class OC_App { * @param array $appInfo app info (from xml) * * @return bool true if compatible, otherwise false + * @deprecated 32.0.0 Use IAppManager::isAppCompatible instead */ public static function isAppCompatible(string $ocVersion, array $appInfo, bool $ignoreMax = false): bool { return Server::get(\OCP\App\IAppManager::class)->isAppCompatible($ocVersion, $appInfo, $ignoreMax); diff --git a/tests/enable_all.php b/tests/enable_all.php index 85e5f3b9247..e9aaf3299a5 100644 --- a/tests/enable_all.php +++ b/tests/enable_all.php @@ -6,10 +6,18 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ +use OC\Installer; +use OCP\App\IAppManager; +use OCP\Server; + require_once __DIR__ . '/../lib/base.php'; function enableApp($app) { - (new \OC_App())->enable($app); + $installer = Server::get(Installer::class); + $appManager = Server::get(IAppManager::class); + + $installer->installApp($app); + $appManager->enableApp($app); echo "Enabled application {$app}\n"; }