diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/composer/composer/autoload_classmap.php | 2 | ||||
-rw-r--r-- | lib/composer/composer/autoload_static.php | 2 | ||||
-rw-r--r-- | lib/private/AppFramework/App.php | 2 | ||||
-rw-r--r-- | lib/private/Console/Application.php | 6 | ||||
-rw-r--r-- | lib/private/Encryption/File.php | 27 | ||||
-rw-r--r-- | lib/private/Encryption/Util.php | 37 | ||||
-rw-r--r-- | lib/private/Server.php | 2 | ||||
-rw-r--r-- | lib/private/URLGenerator.php | 35 | ||||
-rw-r--r-- | lib/private/Updater.php | 2 | ||||
-rw-r--r-- | lib/private/legacy/OC_App.php | 19 | ||||
-rw-r--r-- | lib/public/App.php | 104 | ||||
-rw-r--r-- | lib/public/App/IAppManager.php | 3 | ||||
-rw-r--r-- | lib/public/BackgroundJob.php | 45 |
13 files changed, 68 insertions, 218 deletions
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 8853c1f17f4..b23f8b1fb6c 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -21,7 +21,6 @@ return array( '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 @@ return array( '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 5617430958d..f29c3f97da2 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 feebb32d5bc..170acba0689 100644 --- a/lib/private/AppFramework/App.php +++ b/lib/private/AppFramework/App.php @@ -237,8 +237,6 @@ class App { /** * 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 12d54b48fa9..fc48f57e499 100644 --- a/lib/private/Console/Application.php +++ b/lib/private/Console/Application.php @@ -34,6 +34,7 @@ use OC\MemoryInfo; 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 @@ class Application { $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 844059923bd..87bc35bc159 100644 --- a/lib/private/Encryption/File.php +++ b/lib/private/Encryption/File.php @@ -29,27 +29,22 @@ namespace OC\Encryption; 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<array> */ protected CappedMemoryCache $cache; + private ?IAppManager $appManager = null; public function __construct(Util $util, IRootFolder $rootFolder, @@ -60,6 +55,14 @@ class File implements \OCP\Encryption\IFile { $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 @@ class File implements \OCP\Encryption\IFile { } // 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 174af2e8b89..410ea19da81 100644 --- a/lib/private/Encryption/Util.php +++ b/lib/private/Encryption/Util.php @@ -34,9 +34,12 @@ use OC\Files\Filesystem; 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 @@ class Util { } 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 @@ class Util { * @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 @@ class Util { } /** - * 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 842f72fa1d0..b473f4e75c0 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -353,7 +353,7 @@ class Server extends ServerContainer implements IServerContainer { 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 47979a038ba..6115d4a221e 100644 --- a/lib/private/URLGenerator.php +++ b/lib/private/URLGenerator.php @@ -42,6 +42,8 @@ namespace OC; 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 @@ class URLGenerator implements IURLGenerator { $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 @@ class URLGenerator implements IURLGenerator { $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 @@ class URLGenerator implements IURLGenerator { } $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 @@ class URLGenerator implements IURLGenerator { //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 @@ class URLGenerator implements IURLGenerator { } 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 2c06cffcb19..da989c4db91 100644 --- a/lib/private/Updater.php +++ b/lib/private/Updater.php @@ -378,7 +378,7 @@ class Updater extends BasicEmitter { $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 9fa13a56d38..482fc4e88e7 100644 --- a/lib/private/legacy/OC_App.php +++ b/lib/private/legacy/OC_App.php @@ -679,25 +679,6 @@ class OC_App { } /** - * 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 5103e624316..00000000000 --- a/lib/public/App.php +++ /dev/null @@ -1,104 +0,0 @@ -<?php -/** - * @copyright Copyright (c) 2016, ownCloud, Inc. - * - * @author Bart Visscher <bartv@thisnet.nl> - * @author Christoph Wurst <christoph@winzerhof-wurst.at> - * @author Frank Karlitschek <frank@karlitschek.de> - * @author Georg Ehrke <oc.list@georgehrke.com> - * @author Joas Schilling <coding@schilljs.com> - * @author Jörn Friedrich Dreyer <jfd@butonic.de> - * @author Julius Härtl <jus@bitgrid.net> - * @author Morris Jobke <hey@morrisjobke.de> - * @author Robin McCorkell <robin@mccorkell.me.uk> - * @author Roeland Jago Douma <roeland@famdouma.nl> - * @author Thomas Müller <thomas.mueller@tmit.eu> - * - * @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 <http://www.gnu.org/licenses/> - * - */ -// 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 7473b229427..e0b5c049290 100644 --- a/lib/public/App/IAppManager.php +++ b/lib/public/App/IAppManager.php @@ -36,6 +36,9 @@ use OCP\IUser; /** * 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 2be11ab0a6e..00000000000 --- a/lib/public/BackgroundJob.php +++ /dev/null @@ -1,45 +0,0 @@ -<?php -/** - * @copyright Copyright (c) 2016, ownCloud, Inc. - * - * @author Jakob Sack <mail@jakobsack.de> - * @author Morris Jobke <hey@morrisjobke.de> - * @author Robin Appelman <robin@icewind.nl> - * - * @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 <http://www.gnu.org/licenses/> - * - */ -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) { - } -} |