From 6920e609c02814d03a5dc83792de12d05f1da854 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Wed, 2 Nov 2016 23:26:49 +0100 Subject: Adjust tests and DI for Share.php Signed-off-by: Lukas Reschke --- lib/private/Share/Share.php | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'lib/private/Share/Share.php') diff --git a/lib/private/Share/Share.php b/lib/private/Share/Share.php index b9accda728c..f6da19f3bb8 100644 --- a/lib/private/Share/Share.php +++ b/lib/private/Share/Share.php @@ -45,6 +45,8 @@ namespace OC\Share; use OC\Files\Filesystem; use OCA\FederatedFileSharing\DiscoveryManager; use OCP\DB\QueryBuilder\IQueryBuilder; +use OCP\ILogger; +use OCP\IUserManager; use OCP\IUserSession; use OCP\IDBConnection; use OCP\IConfig; @@ -128,19 +130,35 @@ class Share extends Constants { * Find which users can access a shared item * @param string $path to the file * @param string $ownerUser owner of the file + * @param IUserManager $userManager + * @param ILogger $logger * @param boolean $includeOwner include owner to the list of users with access to the file * @param boolean $returnUserPaths Return an array with the user => path map * @param boolean $recursive take all parent folders into account (default true) * @return array * @note $path needs to be relative to user data dir, e.g. 'file.txt' * not '/admin/data/file.txt' + * @throws \OC\User\NoUserException */ - public static function getUsersSharingFile($path, $ownerUser, $includeOwner = false, $returnUserPaths = false, $recursive = true) { - $userManager = \OC::$server->getUserManager(); + public static function getUsersSharingFile($path, + $ownerUser, + IUserManager $userManager, + ILogger $logger, + $includeOwner = false, + $returnUserPaths = false, + $recursive = true) { $userObject = $userManager->get($ownerUser); if (is_null($userObject)) { - \OCP\Util::writeLog('files', ' Backends provided no user object for ' . $ownerUser, \OCP\Util::ERROR); + $logger->error( + sprintf( + 'Backends provided no user object for %s', + $ownerUser + ), + [ + 'app' => 'files', + ] + ); throw new \OC\User\NoUserException('Backends provided no user object'); } -- cgit v1.2.3