diff --git a/apps/dav/lib/Connector/Sabre/File.php b/apps/dav/lib/Connector/Sabre/File.php
index ebcfdabc6b3c0..94632b265dbf5 100644
--- a/apps/dav/lib/Connector/Sabre/File.php
+++ b/apps/dav/lib/Connector/Sabre/File.php
@@ -553,7 +553,7 @@ public function getContentType() {
* @return array|bool
*/
public function getDirectDownload() {
- if (\OCP\App::isEnabled('encryption')) {
+ if (\OCP\Server::get(\OCP\App\IAppManager::class)->isEnabledForUser('encryption')) {
return [];
}
/** @var \OCP\Files\Storage $storage */
diff --git a/apps/encryption/templates/mail.php b/apps/encryption/templates/mail.php
index 2cfd415b64610..0db4b67d08daa 100644
--- a/apps/encryption/templates/mail.php
+++ b/apps/encryption/templates/mail.php
@@ -7,7 +7,7 @@
-
+
|
| |
diff --git a/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php b/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php
index fe0c7a11ab7bc..c5e1a8b4e7e9e 100644
--- a/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php
+++ b/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php
@@ -35,6 +35,7 @@
use OCP\AppFramework\OCS\OCSException;
use OCP\AppFramework\OCS\OCSForbiddenException;
use OCP\AppFramework\OCSController;
+use OCP\App\IAppManager;
use OCP\Constants;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Federation\Exceptions\ProviderCouldNotAddShareException;
@@ -366,7 +367,7 @@ public function revoke($id) {
* @return bool
*/
private function isS2SEnabled($incoming = false) {
- $result = \OCP\App::isEnabled('files_sharing');
+ $result = \OCP\Server::get(IAppManager::class)->isEnabledForUser('files_sharing');
if ($incoming) {
$result = $result && $this->federatedShareProvider->isIncomingServer2serverShareEnabled();
diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php
index d449a136016e1..975e9fd2557fd 100644
--- a/apps/files_trashbin/lib/Trashbin.php
+++ b/apps/files_trashbin/lib/Trashbin.php
@@ -54,6 +54,7 @@
use OCA\Files_Trashbin\AppInfo\Application;
use OCA\Files_Trashbin\Command\Expire;
use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\App\IAppManager;
use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\NotFoundException;
@@ -395,7 +396,7 @@ public static function move2trash($file_path, $ownerOnly = false) {
* @param integer $timestamp when the file was deleted
*/
private static function retainVersions($filename, $owner, $ownerPath, $timestamp) {
- if (\OCP\App::isEnabled('files_versions') && !empty($ownerPath)) {
+ if (\OCP\Server::get(IAppManager::class)->isEnabledForUser('files_versions') && !empty($ownerPath)) {
$user = OC_User::getUser();
$rootView = new View('/');
@@ -543,7 +544,7 @@ public static function restore($file, $filename, $timestamp) {
* @return false|null
*/
private static function restoreVersions(View $view, $file, $filename, $uniqueFilename, $location, $timestamp) {
- if (\OCP\App::isEnabled('files_versions')) {
+ if (\OCP\Server::get(IAppManager::class)->isEnabledForUser('files_versions')) {
$user = OC_User::getUser();
$rootView = new View('/');
@@ -704,7 +705,7 @@ public static function delete($filename, $user, $timestamp = null) {
*/
private static function deleteVersions(View $view, $file, $filename, $timestamp, $user) {
$size = 0;
- if (\OCP\App::isEnabled('files_versions')) {
+ if (\OCP\Server::get(IAppManager::class)->isEnabledForUser('files_versions')) {
if ($view->is_dir('files_trashbin/versions/' . $file)) {
$size += self::calculateSize(new View('/' . $user . '/files_trashbin/versions/' . $file));
$view->unlink('files_trashbin/versions/' . $file);
diff --git a/apps/provisioning_api/tests/Controller/AppsControllerTest.php b/apps/provisioning_api/tests/Controller/AppsControllerTest.php
index d4237508a315d..187247b9f660f 100644
--- a/apps/provisioning_api/tests/Controller/AppsControllerTest.php
+++ b/apps/provisioning_api/tests/Controller/AppsControllerTest.php
@@ -67,7 +67,7 @@ protected function setUp(): void {
public function testGetAppInfo() {
$result = $this->api->getAppInfo('provisioning_api');
- $expected = \OC_App::getAppInfo('provisioning_api');
+ $expected = $this->appManager->getAppInfo('provisioning_api');
$this->assertEquals($expected, $result->getData());
}
diff --git a/apps/user_ldap/templates/part.settingcontrols.php b/apps/user_ldap/templates/part.settingcontrols.php
index a418885f47ed2..97f80bc13f798 100644
--- a/apps/user_ldap/templates/part.settingcontrols.php
+++ b/apps/user_ldap/templates/part.settingcontrols.php
@@ -4,7 +4,7 @@
-
t('Help'));?>
diff --git a/apps/user_ldap/templates/part.wizardcontrols.php b/apps/user_ldap/templates/part.wizardcontrols.php
index bd84b23c76dbe..d9a6fab60e704 100644
--- a/apps/user_ldap/templates/part.wizardcontrols.php
+++ b/apps/user_ldap/templates/part.wizardcontrols.php
@@ -10,7 +10,7 @@
-
t('Help'));?>
diff --git a/core/Command/Maintenance/Repair.php b/core/Command/Maintenance/Repair.php
index aa0f6a2a08648..2c1fda7c8e4d9 100644
--- a/core/Command/Maintenance/Repair.php
+++ b/core/Command/Maintenance/Repair.php
@@ -82,7 +82,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
if (!$this->appManager->isEnabledForUser($app)) {
continue;
}
- $info = \OC_App::getAppInfo($app);
+ $info = $this->appManager->getAppInfo($app);
if (!is_array($info)) {
continue;
}
diff --git a/core/Command/User/ResetPassword.php b/core/Command/User/ResetPassword.php
index 21bc5cc45b000..294cea38b7104 100644
--- a/core/Command/User/ResetPassword.php
+++ b/core/Command/User/ResetPassword.php
@@ -28,6 +28,7 @@
namespace OC\Core\Command\User;
use OC\Core\Command\Base;
+use OCP\App\IAppManager;
use OCP\IUser;
use OCP\IUserManager;
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
@@ -41,10 +42,12 @@
class ResetPassword extends Base {
protected IUserManager $userManager;
+ private IAppManager $appManager;
- public function __construct(IUserManager $userManager) {
- $this->userManager = $userManager;
+ public function __construct(IUserManager $userManager, IAppManager $appManager) {
parent::__construct();
+ $this->userManager = $userManager;
+ $this->appManager = $appManager;
}
protected function configure() {
@@ -84,7 +87,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
/** @var QuestionHelper $helper */
$helper = $this->getHelper('question');
- if (\OCP\App::isEnabled('encryption')) {
+ if ($this->appManager->isEnabledForUser('encryption', $user)) {
$output->writeln(
'Warning: Resetting the password when using encryption will result in data loss!'
);
diff --git a/core/register_command.php b/core/register_command.php
index d80465e09066e..98a653aed7e41 100644
--- a/core/register_command.php
+++ b/core/register_command.php
@@ -183,7 +183,7 @@
$application->add(new OC\Core\Command\User\Enable(\OC::$server->getUserManager()));
$application->add(new OC\Core\Command\User\LastSeen(\OC::$server->getUserManager()));
$application->add(\OC::$server->get(\OC\Core\Command\User\Report::class));
- $application->add(new OC\Core\Command\User\ResetPassword(\OC::$server->getUserManager()));
+ $application->add(new OC\Core\Command\User\ResetPassword(\OC::$server->getUserManager(), \OC::$server->getAppManager()));
$application->add(new OC\Core\Command\User\Setting(\OC::$server->getUserManager(), \OC::$server->getConfig()));
$application->add(new OC\Core\Command\User\ListCommand(\OC::$server->getUserManager(), \OC::$server->getGroupManager()));
$application->add(new OC\Core\Command\User\Info(\OC::$server->getUserManager(), \OC::$server->getGroupManager()));
diff --git a/core/templates/installation.php b/core/templates/installation.php
index b08f1cd9ac12d..45d9cfc925288 100644
--- a/core/templates/installation.php
+++ b/core/templates/installation.php
@@ -55,7 +55,7 @@
0): ?>
diff --git a/core/templates/layout.base.php b/core/templates/layout.base.php
index 0eb80098889fc..d8a54bfec2e3e 100644
--- a/core/templates/layout.base.php
+++ b/core/templates/layout.base.php
@@ -7,9 +7,9 @@
-
-
-
+
+
+
diff --git a/core/templates/layout.guest.php b/core/templates/layout.guest.php
index 432bc4e860188..c275d9746b719 100644
--- a/core/templates/layout.guest.php
+++ b/core/templates/layout.guest.php
@@ -17,10 +17,10 @@
-
-
-
-
+
+
+
+
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php
index 8853c1f17f48d..b23f8b1fb6c11 100644
--- a/lib/composer/composer/autoload_classmap.php
+++ b/lib/composer/composer/autoload_classmap.php
@@ -21,7 +21,6 @@
'OCP\\Activity\\IManager' => $baseDir . '/lib/public/Activity/IManager.php',
'OCP\\Activity\\IProvider' => $baseDir . '/lib/public/Activity/IProvider.php',
'OCP\\Activity\\ISetting' => $baseDir . '/lib/public/Activity/ISetting.php',
- 'OCP\\App' => $baseDir . '/lib/public/App.php',
'OCP\\AppFramework\\ApiController' => $baseDir . '/lib/public/AppFramework/ApiController.php',
'OCP\\AppFramework\\App' => $baseDir . '/lib/public/AppFramework/App.php',
'OCP\\AppFramework\\AuthPublicShareController' => $baseDir . '/lib/public/AppFramework/AuthPublicShareController.php',
@@ -110,7 +109,6 @@
'OCP\\Authentication\\TwoFactorAuth\\TwoFactorProviderForUserDisabled' => $baseDir . '/lib/public/Authentication/TwoFactorAuth/TwoFactorProviderForUserDisabled.php',
'OCP\\Authentication\\TwoFactorAuth\\TwoFactorProviderForUserEnabled' => $baseDir . '/lib/public/Authentication/TwoFactorAuth/TwoFactorProviderForUserEnabled.php',
'OCP\\AutoloadNotAllowedException' => $baseDir . '/lib/public/AutoloadNotAllowedException.php',
- 'OCP\\BackgroundJob' => $baseDir . '/lib/public/BackgroundJob.php',
'OCP\\BackgroundJob\\IJob' => $baseDir . '/lib/public/BackgroundJob/IJob.php',
'OCP\\BackgroundJob\\IJobList' => $baseDir . '/lib/public/BackgroundJob/IJobList.php',
'OCP\\BackgroundJob\\Job' => $baseDir . '/lib/public/BackgroundJob/Job.php',
diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php
index 5617430958d5d..f29c3f97da2ad 100644
--- a/lib/composer/composer/autoload_static.php
+++ b/lib/composer/composer/autoload_static.php
@@ -54,7 +54,6 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OCP\\Activity\\IManager' => __DIR__ . '/../../..' . '/lib/public/Activity/IManager.php',
'OCP\\Activity\\IProvider' => __DIR__ . '/../../..' . '/lib/public/Activity/IProvider.php',
'OCP\\Activity\\ISetting' => __DIR__ . '/../../..' . '/lib/public/Activity/ISetting.php',
- 'OCP\\App' => __DIR__ . '/../../..' . '/lib/public/App.php',
'OCP\\AppFramework\\ApiController' => __DIR__ . '/../../..' . '/lib/public/AppFramework/ApiController.php',
'OCP\\AppFramework\\App' => __DIR__ . '/../../..' . '/lib/public/AppFramework/App.php',
'OCP\\AppFramework\\AuthPublicShareController' => __DIR__ . '/../../..' . '/lib/public/AppFramework/AuthPublicShareController.php',
@@ -143,7 +142,6 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OCP\\Authentication\\TwoFactorAuth\\TwoFactorProviderForUserDisabled' => __DIR__ . '/../../..' . '/lib/public/Authentication/TwoFactorAuth/TwoFactorProviderForUserDisabled.php',
'OCP\\Authentication\\TwoFactorAuth\\TwoFactorProviderForUserEnabled' => __DIR__ . '/../../..' . '/lib/public/Authentication/TwoFactorAuth/TwoFactorProviderForUserEnabled.php',
'OCP\\AutoloadNotAllowedException' => __DIR__ . '/../../..' . '/lib/public/AutoloadNotAllowedException.php',
- 'OCP\\BackgroundJob' => __DIR__ . '/../../..' . '/lib/public/BackgroundJob.php',
'OCP\\BackgroundJob\\IJob' => __DIR__ . '/../../..' . '/lib/public/BackgroundJob/IJob.php',
'OCP\\BackgroundJob\\IJobList' => __DIR__ . '/../../..' . '/lib/public/BackgroundJob/IJobList.php',
'OCP\\BackgroundJob\\Job' => __DIR__ . '/../../..' . '/lib/public/BackgroundJob/Job.php',
diff --git a/lib/private/AppFramework/App.php b/lib/private/AppFramework/App.php
index feebb32d5bcd6..170acba068956 100644
--- a/lib/private/AppFramework/App.php
+++ b/lib/private/AppFramework/App.php
@@ -237,8 +237,6 @@ public static function main(string $controllerName, string $methodName, DIContai
/**
* Shortcut for calling a controller method and printing the result.
* Similar to App:main except that no headers will be sent.
- * This should be used for example when registering sections via
- * \OC\AppFramework\Core\API::registerAdmin()
*
* @param string $controllerName the name of the controller under which it is
* stored in the DI container
diff --git a/lib/private/Console/Application.php b/lib/private/Console/Application.php
index 12d54b48fa97e..fc48f57e4995d 100644
--- a/lib/private/Console/Application.php
+++ b/lib/private/Console/Application.php
@@ -34,6 +34,7 @@
use OC\NeedsUpdateException;
use OC_App;
use OCP\AppFramework\QueryException;
+use OCP\App\IAppManager;
use OCP\Console\ConsoleEvent;
use OCP\IConfig;
use OCP\IRequest;
@@ -117,13 +118,14 @@ public function loadCommands(
$this->writeMaintenanceModeInfo($input, $output);
} else {
OC_App::loadApps();
- foreach (\OC::$server->getAppManager()->getInstalledApps() as $app) {
+ $appManager = \OCP\Server::get(IAppManager::class);
+ foreach ($appManager->getInstalledApps() as $app) {
$appPath = \OC_App::getAppPath($app);
if ($appPath === false) {
continue;
}
// load commands using info.xml
- $info = \OC_App::getAppInfo($app);
+ $info = $appManager->getAppInfo($app);
if (isset($info['commands'])) {
$this->loadCommandsFromInfoXml($info['commands']);
}
diff --git a/lib/private/Encryption/File.php b/lib/private/Encryption/File.php
index 844059923bd9f..87bc35bc1590c 100644
--- a/lib/private/Encryption/File.php
+++ b/lib/private/Encryption/File.php
@@ -29,27 +29,22 @@
use OCP\Cache\CappedMemoryCache;
use OCA\Files_External\Service\GlobalStoragesService;
+use OCP\App\IAppManager;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
use OCP\Share\IManager;
class File implements \OCP\Encryption\IFile {
-
- /** @var Util */
- protected $util;
-
- /** @var IRootFolder */
- private $rootFolder;
-
- /** @var IManager */
- private $shareManager;
+ protected Util $util;
+ private IRootFolder $rootFolder;
+ private IManager $shareManager;
/**
- * cache results of already checked folders
- *
+ * Cache results of already checked folders
* @var CappedMemoryCache
*/
protected CappedMemoryCache $cache;
+ private ?IAppManager $appManager = null;
public function __construct(Util $util,
IRootFolder $rootFolder,
@@ -60,6 +55,14 @@ public function __construct(Util $util,
$this->shareManager = $shareManager;
}
+ public function getAppManager(): IAppManager {
+ // Lazy evaluate app manager as it initialize the db too early otherwise
+ if ($this->appManager) {
+ return $this->appManager;
+ }
+ $this->appManager = \OCP\Server::get(IAppManager::class);
+ return $this->appManager;
+ }
/**
* Get list of users with access to the file
@@ -110,7 +113,7 @@ public function getAccessList($path) {
}
// check if it is a group mount
- if (\OCP\App::isEnabled("files_external")) {
+ if ($this->getAppManager()->isEnabledForUser("files_external")) {
/** @var GlobalStoragesService $storageService */
$storageService = \OC::$server->get(GlobalStoragesService::class);
$storages = $storageService->getAllStorages();
diff --git a/lib/private/Encryption/Util.php b/lib/private/Encryption/Util.php
index 174af2e8b8995..410ea19da8124 100644
--- a/lib/private/Encryption/Util.php
+++ b/lib/private/Encryption/Util.php
@@ -34,9 +34,12 @@
use OC\Files\View;
use OCA\Files_External\Lib\StorageConfig;
use OCA\Files_External\Service\GlobalStoragesService;
+use OCP\App\IAppManager;
use OCP\Encryption\IEncryptionModule;
use OCP\IConfig;
+use OCP\IGroupManager;
use OCP\IUser;
+use OCP\IUserManager;
class Util {
public const HEADER_START = 'HBEGIN';
@@ -65,29 +68,23 @@ class Util {
/** @var array */
protected $ocHeaderKeys;
- /** @var \OC\User\Manager */
- protected $userManager;
-
/** @var IConfig */
protected $config;
/** @var array paths excluded from encryption */
protected $excludedPaths;
-
- /** @var \OC\Group\Manager $manager */
- protected $groupManager;
+ protected IGroupManager $groupManager;
+ protected IUserManager $userManager;
/**
*
* @param View $rootView
- * @param \OC\User\Manager $userManager
- * @param \OC\Group\Manager $groupManager
* @param IConfig $config
*/
public function __construct(
View $rootView,
- \OC\User\Manager $userManager,
- \OC\Group\Manager $groupManager,
+ IUserManager $userManager,
+ IGroupManager $groupManager,
IConfig $config) {
$this->ocHeaderKeys = [
self::HEADER_ENCRYPTION_MODULE_KEY
@@ -275,7 +272,7 @@ public function getUserWithAccessToMountPoint($users, $groups) {
} else {
$result = array_merge($result, $users);
- $groupManager = \OC::$server->getGroupManager();
+ $groupManager = $this->groupManager;
foreach ($groups as $group) {
$groupObject = $groupManager->get($group);
if ($groupObject) {
@@ -299,7 +296,8 @@ public function getUserWithAccessToMountPoint($users, $groups) {
* @return boolean
*/
public function isSystemWideMountPoint($path, $uid) {
- if (\OCP\App::isEnabled("files_external")) {
+ // No DI here as this initialise the db too soon
+ if (\OCP\Server::get(IAppManager::class)->isEnabledForUser("files_external")) {
/** @var GlobalStoragesService $storageService */
$storageService = \OC::$server->get(GlobalStoragesService::class);
$storages = $storageService->getAllStorages();
@@ -377,32 +375,29 @@ public function isExcluded($path) {
}
/**
- * check if recovery key is enabled for user
- *
- * @param string $uid
- * @return boolean
+ * Check if recovery key is enabled for user
*/
- public function recoveryEnabled($uid) {
+ public function recoveryEnabled(string $uid): bool {
$enabled = $this->config->getUserValue($uid, 'encryption', 'recovery_enabled', '0');
return $enabled === '1';
}
/**
- * set new key storage root
+ * Set new key storage root
*
* @param string $root new key store root relative to the data folder
*/
- public function setKeyStorageRoot($root) {
+ public function setKeyStorageRoot(string $root): void {
$this->config->setAppValue('core', 'encryption_key_storage_root', $root);
}
/**
- * get key storage root
+ * Get key storage root
*
* @return string key storage root
*/
- public function getKeyStorageRoot() {
+ public function getKeyStorageRoot(): string {
return $this->config->getAppValue('core', 'encryption_key_storage_root', '');
}
}
diff --git a/lib/private/Server.php b/lib/private/Server.php
index 842f72fa1d098..b473f4e75c00a 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -353,7 +353,7 @@ public function __construct($webRoot, \OC\Config $config) {
return new Profiler($c->get(SystemConfig::class));
});
- $this->registerService(\OCP\Encryption\IManager::class, function (Server $c) {
+ $this->registerService(\OCP\Encryption\IManager::class, function (Server $c): Encryption\Manager {
$view = new View();
$util = new Encryption\Util(
$view,
diff --git a/lib/private/URLGenerator.php b/lib/private/URLGenerator.php
index 47979a038bae0..6115d4a221e32 100644
--- a/lib/private/URLGenerator.php
+++ b/lib/private/URLGenerator.php
@@ -42,6 +42,8 @@
use OC\Route\Router;
use OCA\Theming\ThemingDefaults;
+use OCP\App\AppPathNotFoundException;
+use OCP\App\IAppManager;
use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IRequest;
@@ -65,12 +67,14 @@ class URLGenerator implements IURLGenerator {
private $router;
/** @var null|string */
private $baseUrl = null;
+ private ?IAppManager $appManager = null;
public function __construct(IConfig $config,
IUserSession $userSession,
ICacheFactory $cacheFactory,
IRequest $request,
- Router $router) {
+ Router $router
+ ) {
$this->config = $config;
$this->userSession = $userSession;
$this->cacheFactory = $cacheFactory;
@@ -78,6 +82,14 @@ public function __construct(IConfig $config,
$this->router = $router;
}
+ private function getAppManager(): IAppManager {
+ if ($this->appManager !== null) {
+ return $this->appManager;
+ }
+ $this->appManager = \OCP\Server::get(IAppManager::class);
+ return $this->appManager;
+ }
+
/**
* Creates an url using a defined route
*
@@ -132,7 +144,7 @@ public function linkTo(string $appName, string $file, array $args = []): string
$frontControllerActive = ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true');
if ($appName !== '') {
- $app_path = \OC_App::getAppPath($appName);
+ $app_path = $this->getAppManager()->getAppPath($appName);
// Check if the app is in the app folder
if ($app_path && file_exists($app_path . '/' . $file)) {
if (substr($file, -3) === 'php') {
@@ -142,7 +154,7 @@ public function linkTo(string $appName, string $file, array $args = []): string
}
$urlLinkTo .= ($file !== 'index.php') ? '/' . $file : '';
} else {
- $urlLinkTo = \OC_App::getAppWebPath($appName) . '/' . $file;
+ $urlLinkTo = $this->getAppManager()->getAppWebPath($appName) . '/' . $file;
}
} else {
$urlLinkTo = \OC::$WEBROOT . '/' . $appName . '/' . $file;
@@ -189,11 +201,20 @@ public function imagePath(string $appName, string $file): string {
//if a theme has a png but not an svg always use the png
$basename = substr(basename($file), 0, -4);
- $appPath = \OC_App::getAppPath($appName);
+ try {
+ $appPath = $this->getAppManager()->getAppPath($appName);
+ } catch (AppPathNotFoundException $e) {
+ if ($appName === 'core' || $appName === '') {
+ $appName = 'core';
+ $appPath = false;
+ } else {
+ throw new RuntimeException('image not found: image: ' . $file . ' webroot: ' . \OC::$WEBROOT . ' serverroot: ' . \OC::$SERVERROOT);
+ }
+ }
// Check if the app is in the app folder
$path = '';
- $themingEnabled = $this->config->getSystemValue('installed', false) && \OCP\App::isEnabled('theming') && \OC_App::isAppLoaded('theming');
+ $themingEnabled = $this->config->getSystemValue('installed', false) && $this->getAppManager()->isEnabledForUser('theming');
$themingImagePath = false;
if ($themingEnabled) {
$themingDefaults = \OC::$server->getThemingDefaults();
@@ -220,10 +241,10 @@ public function imagePath(string $appName, string $file): string {
} elseif ($themingEnabled && $themingImagePath) {
$path = $themingImagePath;
} elseif ($appPath && file_exists($appPath . "/img/$file")) {
- $path = \OC_App::getAppWebPath($appName) . "/img/$file";
+ $path = $this->getAppManager()->getAppWebPath($appName) . "/img/$file";
} elseif ($appPath && !file_exists($appPath . "/img/$basename.svg")
&& file_exists($appPath . "/img/$basename.png")) {
- $path = \OC_App::getAppWebPath($appName) . "/img/$basename.png";
+ $path = $this->getAppManager()->getAppWebPath($appName) . "/img/$basename.png";
} elseif (!empty($appName) and file_exists(\OC::$SERVERROOT . "/$appName/img/$file")) {
$path = \OC::$WEBROOT . "/$appName/img/$file";
} elseif (!empty($appName) and (!file_exists(\OC::$SERVERROOT . "/$appName/img/$basename.svg")
diff --git a/lib/private/Updater.php b/lib/private/Updater.php
index 2c06cffcb199d..da989c4db91c3 100644
--- a/lib/private/Updater.php
+++ b/lib/private/Updater.php
@@ -378,7 +378,7 @@ private function checkAppsRequirements(): void {
$appManager = \OC::$server->getAppManager();
foreach ($apps as $app) {
// check if the app is compatible with this version of Nextcloud
- $info = OC_App::getAppInfo($app);
+ $info = $appManager->getAppInfo($app);
if ($info === null || !OC_App::isAppCompatible($version, $info)) {
if ($appManager->isShipped($app)) {
throw new \UnexpectedValueException('The files of the app "' . $app . '" were not correctly replaced before running the update');
diff --git a/lib/private/legacy/OC_App.php b/lib/private/legacy/OC_App.php
index 9fa13a56d3842..482fc4e88e7d6 100644
--- a/lib/private/legacy/OC_App.php
+++ b/lib/private/legacy/OC_App.php
@@ -678,25 +678,6 @@ public static function getForms(string $type): array {
return $forms;
}
- /**
- * register an admin form to be shown
- *
- * @param string $app
- * @param string $page
- */
- public static function registerAdmin(string $app, string $page) {
- self::$adminForms[] = $app . '/' . $page . '.php';
- }
-
- /**
- * register a personal form to be shown
- * @param string $app
- * @param string $page
- */
- public static function registerPersonal(string $app, string $page) {
- self::$personalForms[] = $app . '/' . $page . '.php';
- }
-
/**
* @param array $entry
* @deprecated 20.0.0 Please register your alternative login option using the registerAlternativeLogin() on the RegistrationContext in your Application class implementing the OCP\Authentication\IAlternativeLogin interface
diff --git a/lib/public/App.php b/lib/public/App.php
deleted file mode 100644
index 5103e624316fa..0000000000000
--- a/lib/public/App.php
+++ /dev/null
@@ -1,104 +0,0 @@
-
- * @author Christoph Wurst
- * @author Frank Karlitschek
- * @author Georg Ehrke
- * @author Joas Schilling
- * @author Jörn Friedrich Dreyer
- * @author Julius Härtl
- * @author Morris Jobke
- * @author Robin McCorkell
- * @author Roeland Jago Douma
- * @author Thomas Müller
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see
- *
- */
-// use OCP namespace for all classes that are considered public.
-// This means that they should be used by apps instead of the internal ownCloud classes
-
-namespace OCP;
-
-/**
- * This class provides functions to manage apps in ownCloud
- * @since 4.0.0
- * @deprecated 14.0.0
- */
-class App {
-
-
- /**
- * Register a Configuration Screen that should appear in the personal settings section.
- * @param string $app appid
- * @param string $page page to be included
- * @return void
- * @since 4.0.0
- * @deprecated 14.0.0 Use settings section in appinfo.xml to register personal admin sections
- */
- public static function registerPersonal($app, $page) {
- \OC_App::registerPersonal($app, $page);
- }
-
- /**
- * Register a Configuration Screen that should appear in the Admin section.
- * @param string $app string appid
- * @param string $page string page to be included
- * @return void
- * @since 4.0.0
- * @deprecated 14.0.0 Use settings section in appinfo.xml to register admin sections
- */
- public static function registerAdmin($app, $page) {
- \OC_App::registerAdmin($app, $page);
- }
-
- /**
- * Read app metadata from the info.xml file
- * @param string $app id of the app or the path of the info.xml file
- * @param boolean $path (optional)
- * @return array|null
- * @deprecated 14.0.0 ise \OC::$server->getAppManager()->getAppInfo($appId)
- * @since 4.0.0
- */
- public static function getAppInfo($app, $path = false) {
- return \OC_App::getAppInfo($app, $path);
- }
-
- /**
- * checks whether or not an app is enabled
- * @param string $app
- * @return boolean
- *
- * This function checks whether or not an app is enabled.
- * @since 4.0.0
- * @deprecated 13.0.0 use \OC::$server->getAppManager()->isEnabledForUser($appId)
- */
- public static function isEnabled($app) {
- return \OC::$server->getAppManager()->isEnabledForUser($app);
- }
-
- /**
- * Get the last version of the app from appinfo/info.xml
- * @param string $app
- * @return string
- * @since 4.0.0
- * @deprecated 14.0.0 use \OC::$server->getAppManager()->getAppVersion($appId)
- */
- public static function getAppVersion($app) {
- return \OC::$server->getAppManager()->getAppVersion($app);
- }
-}
diff --git a/lib/public/App/IAppManager.php b/lib/public/App/IAppManager.php
index 7473b22942713..e0b5c049290d6 100644
--- a/lib/public/App/IAppManager.php
+++ b/lib/public/App/IAppManager.php
@@ -36,6 +36,9 @@
/**
* Interface IAppManager
*
+ * @warning This interface shouldn't be included with dependency injection in
+ * classes used for installing Nextcloud.
+ *
* @since 8.0.0
*/
interface IAppManager {
diff --git a/lib/public/BackgroundJob.php b/lib/public/BackgroundJob.php
deleted file mode 100644
index 2be11ab0a6e47..0000000000000
--- a/lib/public/BackgroundJob.php
+++ /dev/null
@@ -1,45 +0,0 @@
-
- * @author Morris Jobke
- * @author Robin Appelman
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see
- *
- */
-namespace OCP;
-
-/**
- * @since 4.5.0
- * @deprecated 14.0.0
- */
-class BackgroundJob {
- /**
- * @since 5.0.0
- * @deprecated 14.0.0
- */
- public static function getExecutionType() {
- return '';
- }
-
- /**
- * @since 5.0.0
- * @deprecated 14.0.0
- */
- public static function setExecutionType($type) {
- }
-}
diff --git a/tests/lib/Encryption/UtilTest.php b/tests/lib/Encryption/UtilTest.php
index 02155be11ddab..248377fc698e9 100644
--- a/tests/lib/Encryption/UtilTest.php
+++ b/tests/lib/Encryption/UtilTest.php
@@ -8,6 +8,8 @@
use OCA\Files_External\Service\GlobalStoragesService;
use OCP\Encryption\IEncryptionModule;
use OCP\IConfig;
+use OCP\IGroupManager;
+use OCP\IUserManager;
use Test\TestCase;
class UtilTest extends TestCase {
@@ -15,24 +17,21 @@ class UtilTest extends TestCase {
/**
* block size will always be 8192 for a PHP stream
* @see https://bugs.php.net/bug.php?id=21641
- * @var integer
*/
- protected $headerSize = 8192;
+ protected int $headerSize = 8192;
/** @var \PHPUnit\Framework\MockObject\MockObject */
protected $view;
- /** @var \PHPUnit\Framework\MockObject\MockObject */
+ /** @var \PHPUnit\Framework\MockObject\MockObject|IUserManager */
protected $userManager;
- /** @var \PHPUnit\Framework\MockObject\MockObject */
+ /** @var \PHPUnit\Framework\MockObject\MockObject|IGroupManager */
protected $groupManager;
- /** @var \PHPUnit\Framework\MockObject\MockObject */
+ /** @var \PHPUnit\Framework\MockObject\MockObject|IConfig */
private $config;
-
- /** @var \OC\Encryption\Util */
- private $util;
+ private Util $util;
protected function setUp(): void {
parent::setUp();
@@ -40,17 +39,9 @@ protected function setUp(): void {
->disableOriginalConstructor()
->getMock();
- $this->userManager = $this->getMockBuilder('OC\User\Manager')
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->groupManager = $this->getMockBuilder('OC\Group\Manager')
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->config = $this->getMockBuilder(IConfig::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->userManager = $this->createMock(IUserManager::class);
+ $this->groupManager = $this->createMock(IGroupManager::class);
+ $this->config = $this->createMock(IConfig::class);
$this->util = new Util(
$this->view,
diff --git a/tests/lib/UrlGeneratorTest.php b/tests/lib/UrlGeneratorTest.php
index 9e5795fc41e53..7fdbb7fb37ea7 100644
--- a/tests/lib/UrlGeneratorTest.php
+++ b/tests/lib/UrlGeneratorTest.php
@@ -297,7 +297,7 @@ public function testLinkToDefaultPageUrlWithDefaultApps($defaultAppConfig, $expe
$this->assertEquals('http://localhost' . \OC::$WEBROOT . $expectedPath, $this->urlGenerator->linkToDefaultPageUrl());
}
- public function provideDefaultApps() {
+ public function provideDefaultApps(): array {
return [
// none specified, default to files
[
@@ -321,4 +321,18 @@ public function provideDefaultApps() {
],
];
}
+
+ public function imagePathProvider(): array {
+ return [
+ ['core', 'favicon-mask.svg', \OC::$WEBROOT . '/core/img/favicon-mask.svg'],
+ ['files', 'external.svg', \OC::$WEBROOT . '/apps/files/img/external.svg'],
+ ];
+ }
+
+ /**
+ * @dataProvider imagePathProvider
+ */
+ public function testImagePath(string $appName, string $file, string $result): void {
+ $this->assertSame($result, $this->urlGenerator->imagePath($appName, $file));
+ }
}