chore: Cleanup setAppTypes and move it to AppManager

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
Côme Chilliet 2026-04-07 17:27:05 +02:00
parent 13583e8c6b
commit a3102bb2f0
No known key found for this signature in database
GPG key ID: A3E2F658B28C760A
3 changed files with 25 additions and 32 deletions

View file

@ -1042,6 +1042,27 @@ class AppManager implements IAppManager {
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 @@ class AppManager implements IAppManager {
$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);

View file

@ -10,6 +10,7 @@ declare(strict_types=1);
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\Connection;
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 @@ class Installer {
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 @@ class Installer {
$this->config->setAppValue('core', 'public_' . $name, $info['id'] . '/' . $path);
}
\OC_App::setAppTypes($info['id']);
$this->appManager->setAppTypes($info['id'], $info);
return $info['id'];
}

View file

@ -136,34 +136,6 @@ class OC_App {
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.
*