diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Files/Node/Root.php | 54 | ||||
-rw-r--r-- | lib/private/Server.php | 9 |
2 files changed, 41 insertions, 22 deletions
diff --git a/lib/private/Files/Node/Root.php b/lib/private/Files/Node/Root.php index 8434ed64008..515a795d6e0 100644 --- a/lib/private/Files/Node/Root.php +++ b/lib/private/Files/Node/Root.php @@ -36,6 +36,8 @@ use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; use OC\Hooks\PublicEmitter; use OCP\Files\IRootFolder; +use OCP\ILogger; +use OCP\IUserManager; /** * Class Root @@ -57,42 +59,43 @@ use OCP\Files\IRootFolder; * @package OC\Files\Node */ class Root extends Folder implements IRootFolder { - - /** - * @var \OC\Files\Mount\Manager $mountManager - */ + /** @var Manager */ private $mountManager; - - /** - * @var \OC\Hooks\PublicEmitter - */ + /** @var PublicEmitter */ private $emitter; - - /** - * @var \OC\User\User $user - */ + /** @var null|\OC\User\User */ private $user; - + /** @var CappedMemoryCache */ private $userFolderCache; - - /** - * @var IUserMountCache - */ + /** @var IUserMountCache */ private $userMountCache; + /** @var ILogger */ + private $logger; + /** @var IUserManager */ + private $userManager; /** * @param \OC\Files\Mount\Manager $manager * @param \OC\Files\View $view * @param \OC\User\User|null $user * @param IUserMountCache $userMountCache - */ - public function __construct($manager, $view, $user, IUserMountCache $userMountCache) { + * @param ILogger $logger + * @param IUserManager $userManager + */ + public function __construct($manager, + $view, + $user, + IUserMountCache $userMountCache, + ILogger $logger, + IUserManager $userManager) { parent::__construct($this, $view, ''); $this->mountManager = $manager; $this->user = $user; $this->emitter = new PublicEmitter(); $this->userFolderCache = new CappedMemoryCache(); $this->userMountCache = $userMountCache; + $this->logger = $logger; + $this->userManager = $userManager; } /** @@ -345,12 +348,21 @@ class Root extends Folder implements IRootFolder { * * @param String $userId user ID * @return \OCP\Files\Folder + * @throws \OC\User\NoUserException */ public function getUserFolder($userId) { - $userObject = \OC::$server->getUserManager()->get($userId); + $userObject = $this->userManager->get($userId); if (is_null($userObject)) { - \OCP\Util::writeLog('files', 'Backends provided no user object for ' . $userId, \OCP\Util::ERROR); + $this->logger->error( + sprintf( + 'Backends provided no user object for %s', + $userId + ), + [ + 'app' => 'files', + ] + ); throw new \OC\User\NoUserException('Backends provided no user object'); } diff --git a/lib/private/Server.php b/lib/private/Server.php index dca50c15733..9f993ade7fe 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -182,7 +182,14 @@ class Server extends ServerContainer implements IServerContainer { $this->registerService('RootFolder', function (Server $c) { $manager = \OC\Files\Filesystem::getMountManager(null); $view = new View(); - $root = new Root($manager, $view, null, $c->getUserMountCache()); + $root = new Root( + $manager, + $view, + null, + $c->getUserMountCache(), + $this->getLogger(), + $this->getUserManager() + ); $connector = new HookConnector($root, $view); $connector->viewToNode(); return $root; |