diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2024-09-12 16:38:35 +0200 |
---|---|---|
committer | Côme Chilliet <come.chilliet@nextcloud.com> | 2024-09-13 10:08:44 +0200 |
commit | 76f2bc0bfc86a9d1ed34d37c574c7e7a327c0fab (patch) | |
tree | 74bb396c0324eca612b1cec1ec2f0c20a77fb942 /lib | |
parent | 7ed583cb8ee64f77696b0e23f79d8d1b4038bcbc (diff) | |
download | nextcloud-server-76f2bc0bfc86a9d1ed34d37c574c7e7a327c0fab.tar.gz nextcloud-server-76f2bc0bfc86a9d1ed34d37c574c7e7a327c0fab.zip |
fix: Replace OC_App::getAllApps with a method in AppManager
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/App/AppManager.php | 31 | ||||
-rw-r--r-- | lib/private/IntegrityCheck/Checker.php | 4 | ||||
-rw-r--r-- | lib/private/IntegrityCheck/Helpers/AppLocator.php | 9 | ||||
-rw-r--r-- | lib/private/Server.php | 2 | ||||
-rw-r--r-- | lib/private/legacy/OC_App.php | 28 | ||||
-rw-r--r-- | lib/public/App/IAppManager.php | 8 |
6 files changed, 46 insertions, 36 deletions
diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php index 974545cfe92..4ffddef98c3 100644 --- a/lib/private/App/AppManager.php +++ b/lib/private/App/AppManager.php @@ -156,6 +156,37 @@ class AppManager implements IAppManager { } /** + * Get a list of all apps in the apps folder + * + * @return list<string> an array of app names (string IDs) + */ + public function getAllAppsInAppsFolders(): array { + $apps = []; + + foreach (\OC::$APPSROOTS as $apps_dir) { + if (!is_readable($apps_dir['path'])) { + $this->logger->warning('unable to read app folder : ' . $apps_dir['path'], ['app' => 'core']); + continue; + } + $dh = opendir($apps_dir['path']); + + if (is_resource($dh)) { + while (($file = readdir($dh)) !== false) { + if ( + $file[0] != '.' && + is_dir($apps_dir['path'] . '/' . $file) && + is_file($apps_dir['path'] . '/' . $file . '/appinfo/info.xml') + ) { + $apps[] = $file; + } + } + } + } + + return array_values(array_unique($apps)); + } + + /** * List all apps enabled for a user * * @param \OCP\IUser $user diff --git a/lib/private/IntegrityCheck/Checker.php b/lib/private/IntegrityCheck/Checker.php index d38ccf497f4..6443c43d210 100644 --- a/lib/private/IntegrityCheck/Checker.php +++ b/lib/private/IntegrityCheck/Checker.php @@ -46,7 +46,7 @@ class Checker { private ?IConfig $config, private ?IAppConfig $appConfig, ICacheFactory $cacheFactory, - private ?IAppManager $appManager, + private IAppManager $appManager, private IMimeTypeDetector $mimeTypeDetector, ) { $this->cache = $cacheFactory->createDistributed(self::CACHE_KEY); @@ -536,7 +536,7 @@ class Checker { public function runInstanceVerification() { $this->cleanResults(); $this->verifyCoreSignature(); - $appIds = $this->appLocator->getAllApps(); + $appIds = $this->appManager->getAllAppsInAppsFolders(); foreach ($appIds as $appId) { // If an application is shipped a valid signature is required $isShipped = $this->appManager->isShipped($appId); diff --git a/lib/private/IntegrityCheck/Helpers/AppLocator.php b/lib/private/IntegrityCheck/Helpers/AppLocator.php index 3da5cc13227..148a3aeda76 100644 --- a/lib/private/IntegrityCheck/Helpers/AppLocator.php +++ b/lib/private/IntegrityCheck/Helpers/AppLocator.php @@ -30,13 +30,4 @@ class AppLocator { } return $path; } - - /** - * Providers \OC_App::getAllApps() - * - * @return array - */ - public function getAllApps(): array { - return \OC_App::getAllApps(); - } } diff --git a/lib/private/Server.php b/lib/private/Server.php index b0ccb0f4b4d..c514a4b93ff 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -954,10 +954,10 @@ class Server extends ServerContainer implements IServerContainer { if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) { $config = $c->get(\OCP\IConfig::class); $appConfig = $c->get(\OCP\IAppConfig::class); - $appManager = $c->get(IAppManager::class); } else { $config = $appConfig = $appManager = null; } + $appManager = $c->get(IAppManager::class); return new Checker( new EnvironmentHelper(), diff --git a/lib/private/legacy/OC_App.php b/lib/private/legacy/OC_App.php index d72d5fe8522..ef84d35d7bc 100644 --- a/lib/private/legacy/OC_App.php +++ b/lib/private/legacy/OC_App.php @@ -468,30 +468,10 @@ class OC_App { * get a list of all apps in the apps folder * * @return string[] an array of app names (string IDs) - * @todo: change the name of this method to getInstalledApps, which is more accurate + * @deprecated 31.0.0 Use IAppManager::getAllAppsInAppsFolders instead */ public static function getAllApps(): array { - $apps = []; - - foreach (OC::$APPSROOTS as $apps_dir) { - if (!is_readable($apps_dir['path'])) { - \OCP\Server::get(LoggerInterface::class)->warning('unable to read app folder : ' . $apps_dir['path'], ['app' => 'core']); - continue; - } - $dh = opendir($apps_dir['path']); - - if (is_resource($dh)) { - while (($file = readdir($dh)) !== false) { - if ($file[0] != '.' and is_dir($apps_dir['path'] . '/' . $file) and is_file($apps_dir['path'] . '/' . $file . '/appinfo/info.xml')) { - $apps[] = $file; - } - } - } - } - - $apps = array_unique($apps); - - return $apps; + return \OCP\Server::get(IAppManager::class)->getAllAppsInAppsFolders(); } /** @@ -512,9 +492,9 @@ class OC_App { * @return array */ public function listAllApps(): array { - $installedApps = OC_App::getAllApps(); - $appManager = \OC::$server->getAppManager(); + + $installedApps = $appManager->getAllAppsInAppsFolders(); //we don't want to show configuration for these $blacklist = $appManager->getAlwaysEnabledApps(); $appList = []; diff --git a/lib/public/App/IAppManager.php b/lib/public/App/IAppManager.php index 68c3cc771f4..580288fbff7 100644 --- a/lib/public/App/IAppManager.php +++ b/lib/public/App/IAppManager.php @@ -292,4 +292,12 @@ interface IAppManager { * @since 31.0.0 */ public function cleanAppId(string $app): string; + + /** + * Get a list of all apps in the apps folder + * + * @return list<string> an array of app names (string IDs) + * @since 31.0.0 + */ + public function getAllAppsInAppsFolders(): array; } |