aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorF. E Noel Nfebe <fenn25.fn@gmail.com>2024-02-14 10:47:22 +0100
committerGitHub <noreply@github.com>2024-02-14 10:47:22 +0100
commit3fb1674251569e4972554f6500a66986eedfebf3 (patch)
tree38bfb200873e64f43300126a3734dc2a2129af20 /apps
parent0369e4c3021142091a9fd681df25522bdf880507 (diff)
parentc0ce272e9c3a94ff98081c4f90a31ca611d28323 (diff)
downloadnextcloud-server-3fb1674251569e4972554f6500a66986eedfebf3.tar.gz
nextcloud-server-3fb1674251569e4972554f6500a66986eedfebf3.zip
Merge pull request #43461 from nextcloud/fix/get-rid-of-getlogger
chore: Migrate away from OC::$server->getLogger
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/lib/Controller/ShareAPIController.php4
-rw-r--r--apps/files_sharing/lib/DeleteOrphanedSharesJob.php13
-rw-r--r--apps/files_sharing/lib/ShareBackend/File.php3
-rw-r--r--apps/files_sharing/lib/SharedMount.php11
-rw-r--r--apps/user_ldap/lib/Configuration.php4
-rw-r--r--apps/user_ldap/lib/GroupPluginManager.php3
-rw-r--r--apps/user_ldap/lib/Mapping/AbstractMapping.php3
-rw-r--r--apps/user_ldap/lib/UserPluginManager.php5
-rw-r--r--apps/user_ldap/tests/Integration/AbstractIntegrationTest.php2
9 files changed, 31 insertions, 17 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php
index 5762aa47b3b..71d21cfb55c 100644
--- a/apps/files_sharing/lib/Controller/ShareAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareAPIController.php
@@ -850,11 +850,11 @@ class ShareAPIController extends OCSController {
try {
$share = $this->shareManager->createShare($share);
} catch (GenericShareException $e) {
- \OC::$server->getLogger()->logException($e);
+ \OCP\Server::get(LoggerInterface::class)->error($e->getMessage(), ['exception' => $e]);
$code = $e->getCode() === 0 ? 403 : $e->getCode();
throw new OCSException($e->getHint(), $code);
} catch (\Exception $e) {
- \OC::$server->getLogger()->logException($e);
+ \OCP\Server::get(LoggerInterface::class)->error($e->getMessage(), ['exception' => $e]);
throw new OCSForbiddenException($e->getMessage(), $e);
}
diff --git a/apps/files_sharing/lib/DeleteOrphanedSharesJob.php b/apps/files_sharing/lib/DeleteOrphanedSharesJob.php
index d2cc39ff060..2d166da2010 100644
--- a/apps/files_sharing/lib/DeleteOrphanedSharesJob.php
+++ b/apps/files_sharing/lib/DeleteOrphanedSharesJob.php
@@ -26,6 +26,9 @@ namespace OCA\Files_Sharing;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;
+use OCP\IDBConnection;
+use OCP\Server;
+use Psr\Log\LoggerInterface;
/**
* Delete all share entries that have no matching entries in the file cache table.
@@ -33,10 +36,8 @@ use OCP\BackgroundJob\TimedJob;
class DeleteOrphanedSharesJob extends TimedJob {
/**
* Default interval in minutes
- *
- * @var int $defaultIntervalMin
**/
- protected $defaultIntervalMin = 15;
+ protected int $defaultIntervalMin = 15;
/**
* sets the correct interval for this timed job
@@ -53,15 +54,15 @@ class DeleteOrphanedSharesJob extends TimedJob {
* @param array $argument unused argument
*/
public function run($argument) {
- $connection = \OC::$server->getDatabaseConnection();
- $logger = \OC::$server->getLogger();
+ $connection = Server::get(IDBConnection::class);
+ $logger = Server::get(LoggerInterface::class);
$sql =
'DELETE FROM `*PREFIX*share` ' .
'WHERE `item_type` in (\'file\', \'folder\') ' .
'AND NOT EXISTS (SELECT `fileid` FROM `*PREFIX*filecache` WHERE `file_source` = `fileid`)';
- $deletedEntries = $connection->executeUpdate($sql);
+ $deletedEntries = $connection->executeStatement($sql);
$logger->debug("$deletedEntries orphaned share(s) deleted", ['app' => 'DeleteOrphanedSharesJob']);
}
}
diff --git a/apps/files_sharing/lib/ShareBackend/File.php b/apps/files_sharing/lib/ShareBackend/File.php
index c84cbd66c67..23096d64156 100644
--- a/apps/files_sharing/lib/ShareBackend/File.php
+++ b/apps/files_sharing/lib/ShareBackend/File.php
@@ -35,6 +35,7 @@ namespace OCA\Files_Sharing\ShareBackend;
use OCA\FederatedFileSharing\FederatedShareProvider;
use OCP\Share\IShare;
+use Psr\Log\LoggerInterface;
class File implements \OCP\Share_Backend_File_Dependent {
public const FORMAT_SHARED_STORAGE = 0;
@@ -233,7 +234,7 @@ class File implements \OCP\Share_Backend_File_Dependent {
if (isset($fileOwner)) {
$source['fileOwner'] = $fileOwner;
} else {
- \OC::$server->getLogger()->error('No owner found for reshare', ['app' => 'files_sharing']);
+ \OCP\Server::get(LoggerInterface::class)->error('No owner found for reshare', ['app' => 'files_sharing']);
}
return $source;
diff --git a/apps/files_sharing/lib/SharedMount.php b/apps/files_sharing/lib/SharedMount.php
index 7dc24936d6b..66a3b619df0 100644
--- a/apps/files_sharing/lib/SharedMount.php
+++ b/apps/files_sharing/lib/SharedMount.php
@@ -40,6 +40,7 @@ use OCP\Files\Storage\IStorageFactory;
use OCP\ICache;
use OCP\IUser;
use OCP\Share\Events\VerifyMountPointEvent;
+use Psr\Log\LoggerInterface;
/**
* Shared mount points can be moved by the user
@@ -198,7 +199,7 @@ class SharedMount extends MountPoint implements MoveableMount, ISharedMountPoint
// it is not a file relative to data/user/files
if (count($split) < 3 || $split[1] !== 'files') {
- \OC::$server->getLogger()->error('Can not strip userid and "files/" from path: ' . $path, ['app' => 'files_sharing']);
+ \OCP\Server::get(LoggerInterface::class)->error('Can not strip userid and "files/" from path: ' . $path, ['app' => 'files_sharing']);
throw new \OCA\Files_Sharing\Exceptions\BrokenPath('Path does not start with /user/files', 10);
}
@@ -226,7 +227,13 @@ class SharedMount extends MountPoint implements MoveableMount, ISharedMountPoint
$this->setMountPoint($target);
$this->storage->setMountPoint($relTargetPath);
} catch (\Exception $e) {
- \OC::$server->getLogger()->logException($e, ['app' => 'files_sharing', 'message' => 'Could not rename mount point for shared folder "' . $this->getMountPoint() . '" to "' . $target . '"']);
+ \OCP\Server::get(LoggerInterface::class)->error(
+ 'Could not rename mount point for shared folder "' . $this->getMountPoint() . '" to "' . $target . '"',
+ [
+ 'app' => 'files_sharing',
+ 'exception' => $e,
+ ]
+ );
}
return $result;
diff --git a/apps/user_ldap/lib/Configuration.php b/apps/user_ldap/lib/Configuration.php
index b009ba3f480..2791324be5b 100644
--- a/apps/user_ldap/lib/Configuration.php
+++ b/apps/user_ldap/lib/Configuration.php
@@ -35,6 +35,8 @@
*/
namespace OCA\User_LDAP;
+use Psr\Log\LoggerInterface;
+
/**
* @property int ldapPagingSize holds an integer
* @property string ldapUserAvatarRule
@@ -598,7 +600,7 @@ class Configuration {
return [strtolower($attribute)];
}
if ($value !== self::AVATAR_PREFIX_DEFAULT) {
- \OC::$server->getLogger()->warning('Invalid config value to ldapUserAvatarRule; falling back to default.');
+ \OCP\Server::get(LoggerInterface::class)->warning('Invalid config value to ldapUserAvatarRule; falling back to default.');
}
return $defaultAttributes;
}
diff --git a/apps/user_ldap/lib/GroupPluginManager.php b/apps/user_ldap/lib/GroupPluginManager.php
index d99e17d7673..92bf0cb8888 100644
--- a/apps/user_ldap/lib/GroupPluginManager.php
+++ b/apps/user_ldap/lib/GroupPluginManager.php
@@ -24,6 +24,7 @@
namespace OCA\User_LDAP;
use OCP\GroupInterface;
+use Psr\Log\LoggerInterface;
class GroupPluginManager {
private int $respondToActions = 0;
@@ -58,7 +59,7 @@ class GroupPluginManager {
foreach ($this->which as $action => $v) {
if ((bool)($respondToActions & $action)) {
$this->which[$action] = $plugin;
- \OC::$server->getLogger()->debug("Registered action ".$action." to plugin ".get_class($plugin), ['app' => 'user_ldap']);
+ \OCP\Server::get(LoggerInterface::class)->debug("Registered action ".$action." to plugin ".get_class($plugin), ['app' => 'user_ldap']);
}
}
}
diff --git a/apps/user_ldap/lib/Mapping/AbstractMapping.php b/apps/user_ldap/lib/Mapping/AbstractMapping.php
index 3f05091a537..40bc8624c3c 100644
--- a/apps/user_ldap/lib/Mapping/AbstractMapping.php
+++ b/apps/user_ldap/lib/Mapping/AbstractMapping.php
@@ -30,6 +30,7 @@ use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use OCP\DB\IPreparedStatement;
use OCP\DB\QueryBuilder\IQueryBuilder;
+use Psr\Log\LoggerInterface;
/**
* Class AbstractMapping
@@ -351,7 +352,7 @@ abstract class AbstractMapping {
*/
public function map($fdn, $name, $uuid) {
if (mb_strlen($fdn) > 4000) {
- \OC::$server->getLogger()->error(
+ \OCP\Server::get(LoggerInterface::class)->error(
'Cannot map, because the DN exceeds 4000 characters: {dn}',
[
'app' => 'user_ldap',
diff --git a/apps/user_ldap/lib/UserPluginManager.php b/apps/user_ldap/lib/UserPluginManager.php
index 516338f006b..527c6684103 100644
--- a/apps/user_ldap/lib/UserPluginManager.php
+++ b/apps/user_ldap/lib/UserPluginManager.php
@@ -26,6 +26,7 @@
namespace OCA\User_LDAP;
use OC\User\Backend;
+use Psr\Log\LoggerInterface;
class UserPluginManager {
private int $respondToActions = 0;
@@ -62,12 +63,12 @@ class UserPluginManager {
foreach ($this->which as $action => $v) {
if (is_int($action) && (bool)($respondToActions & $action)) {
$this->which[$action] = $plugin;
- \OC::$server->getLogger()->debug("Registered action ".$action." to plugin ".get_class($plugin), ['app' => 'user_ldap']);
+ \OCP\Server::get(LoggerInterface::class)->debug("Registered action ".$action." to plugin ".get_class($plugin), ['app' => 'user_ldap']);
}
}
if (method_exists($plugin, 'deleteUser')) {
$this->which['deleteUser'] = $plugin;
- \OC::$server->getLogger()->debug("Registered action deleteUser to plugin ".get_class($plugin), ['app' => 'user_ldap']);
+ \OCP\Server::get(LoggerInterface::class)->debug("Registered action deleteUser to plugin ".get_class($plugin), ['app' => 'user_ldap']);
}
}
diff --git a/apps/user_ldap/tests/Integration/AbstractIntegrationTest.php b/apps/user_ldap/tests/Integration/AbstractIntegrationTest.php
index 58475a2bea9..5ec04484bef 100644
--- a/apps/user_ldap/tests/Integration/AbstractIntegrationTest.php
+++ b/apps/user_ldap/tests/Integration/AbstractIntegrationTest.php
@@ -143,7 +143,7 @@ abstract class AbstractIntegrationTest {
* initializes the Access test instance
*/
protected function initAccess() {
- $this->access = new Access($this->connection, $this->ldap, $this->userManager, $this->helper, \OC::$server->getConfig(), \OC::$server->getLogger());
+ $this->access = new Access($this->connection, $this->ldap, $this->userManager, $this->helper, \OC::$server->getConfig(), \OCP\Server::get(LoggerInterface::class));
}
/**