From a3102bb2f015714fb96cfd874822be3dccaca7f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Tue, 7 Apr 2026 17:27:05 +0200 Subject: [PATCH] chore: Cleanup setAppTypes and move it to AppManager MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- lib/private/App/AppManager.php | 23 ++++++++++++++++++++++- lib/private/Installer.php | 6 +++--- lib/private/legacy/OC_App.php | 28 ---------------------------- 3 files changed, 25 insertions(+), 32 deletions(-) diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php index 9bf5909cce99b..8176ce4723ceb 100644 --- a/lib/private/App/AppManager.php +++ b/lib/private/App/AppManager.php @@ -1042,6 +1042,27 @@ public function cleanAppId(string $app): string { return $cleanAppId; } + /** + * Read app types from info.xml and cache them in the database + */ + public function setAppTypes(string $app, array $appData): void { + if (isset($appData['types'])) { + $appTypes = implode(',', $appData['types']); + } else { + $appTypes = ''; + $appData['types'] = []; + } + + $this->config->setAppValue($app, 'types', $appTypes); + + if ($this->hasProtectedAppType($appData['types'])) { + $enabled = $this->config->getAppValue($app, 'enabled', 'yes'); + if ($enabled !== 'yes' && $enabled !== 'no') { + $this->config->setAppValue($app, 'enabled', 'yes'); + } + } + } + /** * Run upgrade tasks for an app after the code has already been updated * @@ -1099,7 +1120,7 @@ public function upgradeApp(string $appId): bool { $this->config->setAppValue('core', 'public_' . $name, $appId . '/' . $path); } - \OC_App::setAppTypes($appId); + $this->setAppTypes($appId, $appData); $version = $this->getAppVersion($appId); $this->config->setAppValue($appId, 'installed_version', $version); diff --git a/lib/private/Installer.php b/lib/private/Installer.php index 897acd02cb9be..33ac13c83a769 100644 --- a/lib/private/Installer.php +++ b/lib/private/Installer.php @@ -10,6 +10,7 @@ namespace OC; use Doctrine\DBAL\Exception\TableExistsException; +use OC\App\AppManager; use OC\App\AppStore\AppNotFoundException; use OC\App\AppStore\Bundles\Bundle; use OC\App\AppStore\Fetcher\AppFetcher; @@ -19,7 +20,6 @@ use OC\DB\MigrationService; use OC\Files\FilenameValidator; use OCP\App\AppPathNotFoundException; -use OCP\App\IAppManager; use OCP\BackgroundJob\IJobList; use OCP\Files; use OCP\HintException; @@ -46,7 +46,7 @@ public function __construct( private ITempManager $tempManager, private LoggerInterface $logger, private IConfig $config, - private IAppManager $appManager, + private AppManager $appManager, private IFactory $l10nFactory, private bool $isCLI, ) { @@ -583,7 +583,7 @@ private function installAppLastSteps(string $appPath, array $info, ?IOutput $out $this->config->setAppValue('core', 'public_' . $name, $info['id'] . '/' . $path); } - \OC_App::setAppTypes($info['id']); + $this->appManager->setAppTypes($info['id'], $info); return $info['id']; } diff --git a/lib/private/legacy/OC_App.php b/lib/private/legacy/OC_App.php index 76e5fda71fb11..6dd425dc1aacf 100644 --- a/lib/private/legacy/OC_App.php +++ b/lib/private/legacy/OC_App.php @@ -136,34 +136,6 @@ public static function isType(string $app, array $types): bool { return Server::get(IAppManager::class)->isType($app, $types); } - /** - * read app types from info.xml and cache them in the database - */ - public static function setAppTypes(string $app): void { - $appManager = Server::get(IAppManager::class); - $appData = $appManager->getAppInfo($app); - if (!is_array($appData)) { - return; - } - - if (isset($appData['types'])) { - $appTypes = implode(',', $appData['types']); - } else { - $appTypes = ''; - $appData['types'] = []; - } - - $config = Server::get(IConfig::class); - $config->setAppValue($app, 'types', $appTypes); - - if ($appManager->hasProtectedAppType($appData['types'])) { - $enabled = $config->getAppValue($app, 'enabled', 'yes'); - if ($enabled !== 'yes' && $enabled !== 'no') { - $config->setAppValue($app, 'enabled', 'yes'); - } - } - } - /** * Returns apps enabled for the current user. *