aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/lib
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2021-11-09 15:11:15 +0100
committerCôme Chilliet <come.chilliet@nextcloud.com>2021-11-09 15:11:15 +0100
commit6b960de47cabaa7a231e72479012ba4dcbc2e882 (patch)
tree362d7052250df7f8ec341f9035f4320666a9e748 /apps/user_ldap/lib
parent81b60c14c985b0a46fd31733db2add9efd7bedba (diff)
downloadnextcloud-server-6b960de47cabaa7a231e72479012ba4dcbc2e882.tar.gz
nextcloud-server-6b960de47cabaa7a231e72479012ba4dcbc2e882.zip
Get rid of LogWrapper calling deprecated logger and use LoggerInterface from PSR instead
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'apps/user_ldap/lib')
-rw-r--r--apps/user_ldap/lib/LogWrapper.php39
-rw-r--r--apps/user_ldap/lib/Proxy.php3
-rw-r--r--apps/user_ldap/lib/User/Manager.php12
-rw-r--r--apps/user_ldap/lib/User/User.php34
4 files changed, 20 insertions, 68 deletions
diff --git a/apps/user_ldap/lib/LogWrapper.php b/apps/user_ldap/lib/LogWrapper.php
deleted file mode 100644
index e03378802d3..00000000000
--- a/apps/user_ldap/lib/LogWrapper.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- *
- * @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 OCA\User_LDAP;
-
-/**
- * @brief wraps around static Nextcloud core methods
- */
-class LogWrapper {
- protected $app = 'user_ldap';
-
- /**
- * @brief states whether the filesystem was loaded
- * @return bool
- */
- public function log($msg, $level) {
- \OCP\Util::writeLog($this->app, $msg, $level);
- }
-}
diff --git a/apps/user_ldap/lib/Proxy.php b/apps/user_ldap/lib/Proxy.php
index 8fb6a7f4c0f..d9546a163ab 100644
--- a/apps/user_ldap/lib/Proxy.php
+++ b/apps/user_ldap/lib/Proxy.php
@@ -75,7 +75,6 @@ abstract class Proxy {
if ($fs === null) {
$ocConfig = \OC::$server->getConfig();
$fs = new FilesystemHelper();
- $log = new LogWrapper();
$avatarM = \OC::$server->getAvatarManager();
$db = \OC::$server->getDatabaseConnection();
$userMap = new UserMapping($db);
@@ -86,7 +85,7 @@ abstract class Proxy {
$logger = \OC::$server->get(LoggerInterface::class);
}
$userManager =
- new Manager($ocConfig, $fs, $log, $avatarM, new \OCP\Image(),
+ new Manager($ocConfig, $fs, $logger, $avatarM, new \OCP\Image(),
$coreUserManager, $coreNotificationManager, $shareManager);
$connector = new Connection($this->ldap, $configPrefix);
$access = new Access($connector, $this->ldap, $userManager, new Helper($ocConfig, \OC::$server->getDatabaseConnection()), $ocConfig, $coreUserManager, $logger);
diff --git a/apps/user_ldap/lib/User/Manager.php b/apps/user_ldap/lib/User/Manager.php
index 87f75f093db..63af3cf1770 100644
--- a/apps/user_ldap/lib/User/Manager.php
+++ b/apps/user_ldap/lib/User/Manager.php
@@ -31,7 +31,6 @@ namespace OCA\User_LDAP\User;
use OC\Cache\CappedMemoryCache;
use OCA\User_LDAP\Access;
use OCA\User_LDAP\FilesystemHelper;
-use OCA\User_LDAP\LogWrapper;
use OCP\IAvatarManager;
use OCP\IConfig;
use OCP\IDBConnection;
@@ -39,6 +38,7 @@ use OCP\Image;
use OCP\IUserManager;
use OCP\Notification\IManager as INotificationManager;
use OCP\Share\IManager;
+use Psr\Log\LoggerInterface;
/**
* Manager
@@ -65,8 +65,8 @@ class Manager {
/** @var FilesystemHelper */
protected $ocFilesystem;
- /** @var LogWrapper */
- protected $ocLog;
+ /** @var LoggerInterface */
+ protected $logger;
/** @var Image */
protected $image;
@@ -88,7 +88,7 @@ class Manager {
public function __construct(
IConfig $ocConfig,
FilesystemHelper $ocFilesystem,
- LogWrapper $ocLog,
+ LoggerInterface $logger,
IAvatarManager $avatarManager,
Image $image,
IUserManager $userManager,
@@ -97,7 +97,7 @@ class Manager {
) {
$this->ocConfig = $ocConfig;
$this->ocFilesystem = $ocFilesystem;
- $this->ocLog = $ocLog;
+ $this->logger = $logger;
$this->avatarManager = $avatarManager;
$this->image = $image;
$this->userManager = $userManager;
@@ -126,7 +126,7 @@ class Manager {
private function createAndCache($dn, $uid) {
$this->checkAccess();
$user = new User($uid, $dn, $this->access, $this->ocConfig,
- $this->ocFilesystem, clone $this->image, $this->ocLog,
+ $this->ocFilesystem, clone $this->image, $this->logger,
$this->avatarManager, $this->userManager,
$this->notificationManager);
$this->usersByDN[$dn] = $user;
diff --git a/apps/user_ldap/lib/User/User.php b/apps/user_ldap/lib/User/User.php
index b09fbd18327..431009f047a 100644
--- a/apps/user_ldap/lib/User/User.php
+++ b/apps/user_ldap/lib/User/User.php
@@ -35,7 +35,6 @@ use OCA\User_LDAP\Access;
use OCA\User_LDAP\Connection;
use OCA\User_LDAP\Exceptions\AttributeNotSet;
use OCA\User_LDAP\FilesystemHelper;
-use OCA\User_LDAP\LogWrapper;
use OCP\IAvatarManager;
use OCP\IConfig;
use OCP\ILogger;
@@ -43,6 +42,7 @@ use OCP\Image;
use OCP\IUser;
use OCP\IUserManager;
use OCP\Notification\IManager as INotificationManager;
+use Psr\Log\LoggerInterface;
/**
* User
@@ -71,9 +71,9 @@ class User {
*/
protected $image;
/**
- * @var LogWrapper
+ * @var LoggerInterface
*/
- protected $log;
+ private $logger;
/**
* @var IAvatarManager
*/
@@ -112,24 +112,16 @@ class User {
* @brief constructor, make sure the subclasses call this one!
* @param string $username the internal username
* @param string $dn the LDAP DN
- * @param Access $access
- * @param IConfig $config
- * @param FilesystemHelper $fs
- * @param Image $image any empty instance
- * @param LogWrapper $log
- * @param IAvatarManager $avatarManager
- * @param IUserManager $userManager
- * @param INotificationManager $notificationManager
*/
public function __construct($username, $dn, Access $access,
IConfig $config, FilesystemHelper $fs, Image $image,
- LogWrapper $log, IAvatarManager $avatarManager, IUserManager $userManager,
+ LoggerInterface $logger, IAvatarManager $avatarManager, IUserManager $userManager,
INotificationManager $notificationManager) {
if ($username === null) {
- $log->log("uid for '$dn' must not be null!", ILogger::ERROR);
+ $logger->error("uid for '$dn' must not be null!", ['app' => 'user_ldap']);
throw new \InvalidArgumentException('uid must not be null!');
} elseif ($username === '') {
- $log->log("uid for '$dn' must not be an empty string", ILogger::ERROR);
+ $logger->error("uid for '$dn' must not be an empty string", ['app' => 'user_ldap']);
throw new \InvalidArgumentException('uid must not be an empty string!');
}
@@ -140,7 +132,7 @@ class User {
$this->dn = $dn;
$this->uid = $username;
$this->image = $image;
- $this->log = $log;
+ $this->logger = $logger;
$this->avatarManager = $avatarManager;
$this->userManager = $userManager;
$this->notificationManager = $notificationManager;
@@ -493,19 +485,19 @@ class User {
if ($aQuota && (count($aQuota) > 0) && $this->verifyQuotaValue($aQuota[0])) {
$quota = $aQuota[0];
} elseif (is_array($aQuota) && isset($aQuota[0])) {
- $this->log->log('no suitable LDAP quota found for user ' . $this->uid . ': [' . $aQuota[0] . ']', ILogger::DEBUG);
+ $this->logger->debug('no suitable LDAP quota found for user ' . $this->uid . ': [' . $aQuota[0] . ']', ['app' => 'user_ldap']);
}
} elseif ($this->verifyQuotaValue($valueFromLDAP)) {
$quota = $valueFromLDAP;
} else {
- $this->log->log('no suitable LDAP quota found for user ' . $this->uid . ': [' . $valueFromLDAP . ']', ILogger::DEBUG);
+ $this->logger->debug('no suitable LDAP quota found for user ' . $this->uid . ': [' . $valueFromLDAP . ']', ['app' => 'user_ldap']);
}
if ($quota === false && $this->verifyQuotaValue($defaultQuota)) {
// quota not found using the LDAP attribute (or not parseable). Try the default quota
$quota = $defaultQuota;
} elseif ($quota === false) {
- $this->log->log('no suitable default quota found for user ' . $this->uid . ': [' . $defaultQuota . ']', ILogger::DEBUG);
+ $this->logger->debug('no suitable default quota found for user ' . $this->uid . ': [' . $defaultQuota . ']', ['app' => 'user_ldap']);
return;
}
@@ -513,7 +505,7 @@ class User {
if ($targetUser instanceof IUser) {
$targetUser->setQuota($quota);
} else {
- $this->log->log('trying to set a quota for user ' . $this->uid . ' but the user is missing', ILogger::INFO);
+ $this->logger->info('trying to set a quota for user ' . $this->uid . ' but the user is missing', ['app' => 'user_ldap']);
}
}
@@ -573,7 +565,7 @@ class User {
*/
private function setOwnCloudAvatar() {
if (!$this->image->valid()) {
- $this->log->log('avatar image data from LDAP invalid for '.$this->dn, ILogger::ERROR);
+ $this->logger->error('avatar image data from LDAP invalid for '.$this->dn, ['app' => 'user_ldap']);
return false;
}
@@ -581,7 +573,7 @@ class User {
//make sure it is a square and not bigger than 128x128
$size = min([$this->image->width(), $this->image->height(), 128]);
if (!$this->image->centerCrop($size)) {
- $this->log->log('croping image for avatar failed for '.$this->dn, ILogger::ERROR);
+ $this->logger->error('croping image for avatar failed for '.$this->dn, ['app' => 'user_ldap']);
return false;
}