diff options
99 files changed, 435 insertions, 604 deletions
diff --git a/apps/dav/tests/unit/Comments/RootCollectionTest.php b/apps/dav/tests/unit/Comments/RootCollectionTest.php index 6cc038bb7b8..8537eb9ab17 100644 --- a/apps/dav/tests/unit/Comments/RootCollectionTest.php +++ b/apps/dav/tests/unit/Comments/RootCollectionTest.php @@ -43,7 +43,7 @@ class RootCollectionTest extends \Test\TestCase { protected $commentsManager; /** @var \OCP\IUserManager|\PHPUnit\Framework\MockObject\MockObject */ protected $userManager; - /** @var \OCP\ILogger|\PHPUnit\Framework\MockObject\MockObject */ + /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */ protected $logger; /** @var \OCA\DAV\Comments\RootCollection */ protected $collection; @@ -70,14 +70,14 @@ class RootCollectionTest extends \Test\TestCase { $this->userSession = $this->getMockBuilder(IUserSession::class) ->disableOriginalConstructor() ->getMock(); - $this->logger = $this->getMockBuilder(ILogger::class) + $this->logger = $this->getMockBuilder(LoggerInterface::class) ->disableOriginalConstructor() ->getMock(); $this->dispatcher = new SymfonyAdapter( new EventDispatcher( new \Symfony\Component\EventDispatcher\EventDispatcher(), \OC::$server, - $this->createMock(LoggerInterface::class) + $this->logger ), $this->logger ); @@ -87,7 +87,7 @@ class RootCollectionTest extends \Test\TestCase { $this->userManager, $this->userSession, $this->dispatcher, - $this->logger + $this->createMock(ILogger::class) ); } diff --git a/apps/files/lib/BackgroundJob/ScanFiles.php b/apps/files/lib/BackgroundJob/ScanFiles.php index 84846b9b55d..07794a28774 100644 --- a/apps/files/lib/BackgroundJob/ScanFiles.php +++ b/apps/files/lib/BackgroundJob/ScanFiles.php @@ -29,7 +29,7 @@ use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\EventDispatcher\IEventDispatcher; use OCP\IConfig; use OCP\IDBConnection; -use OCP\ILogger; +use Psr\Log\LoggerInterface; /** * Class ScanFiles is a background job used to run the file scanner over the user @@ -42,23 +42,16 @@ class ScanFiles extends \OC\BackgroundJob\TimedJob { private $config; /** @var IEventDispatcher */ private $dispatcher; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; private $connection; /** Amount of users that should get scanned per execution */ public const USERS_PER_SESSION = 500; - /** - * @param IConfig $config - * @param IEventDispatcher $dispatcher - * @param ILogger $logger - * @param IDBConnection $connection - */ public function __construct( IConfig $config, IEventDispatcher $dispatcher, - ILogger $logger, + LoggerInterface $logger, IDBConnection $connection ) { // Run once per 10 minutes @@ -83,7 +76,7 @@ class ScanFiles extends \OC\BackgroundJob\TimedJob { ); $scanner->backgroundScan(''); } catch (\Exception $e) { - $this->logger->logException($e, ['app' => 'files']); + $this->logger->error($e->getMessage(), ['exception' => $e, 'app' => 'files']); } \OC_Util::tearDownFS(); } diff --git a/apps/files/lib/Command/Scan.php b/apps/files/lib/Command/Scan.php index ff96fbf2dab..47f1caabc78 100644 --- a/apps/files/lib/Command/Scan.php +++ b/apps/files/lib/Command/Scan.php @@ -43,6 +43,7 @@ use OCP\Files\Mount\IMountPoint; use OCP\Files\NotFoundException; use OCP\Files\StorageNotAvailableException; use OCP\IUserManager; +use Psr\Log\LoggerInterface; use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -111,7 +112,7 @@ class Scan extends Base { $user, new ConnectionAdapter($connection), \OC::$server->query(IEventDispatcher::class), - \OC::$server->getLogger() + \OC::$server->get(LoggerInterface::class) ); # check on each file/folder if there was a user interrupt (ctrl-c) and throw an exception diff --git a/apps/files/lib/Command/ScanAppData.php b/apps/files/lib/Command/ScanAppData.php index 59281b52bc4..a5e9d99f804 100644 --- a/apps/files/lib/Command/ScanAppData.php +++ b/apps/files/lib/Command/ScanAppData.php @@ -38,6 +38,7 @@ use OCP\Files\IRootFolder; use OCP\Files\NotFoundException; use OCP\Files\StorageNotAvailableException; use OCP\IConfig; +use Psr\Log\LoggerInterface; use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -95,7 +96,7 @@ class ScanAppData extends Base { null, new ConnectionAdapter($connection), \OC::$server->query(IEventDispatcher::class), - \OC::$server->getLogger() + \OC::$server->get(LoggerInterface::class) ); # check on each file/folder if there was a user interrupt (ctrl-c) and throw an exception diff --git a/apps/files/tests/BackgroundJob/ScanFilesTest.php b/apps/files/tests/BackgroundJob/ScanFilesTest.php index 04eeff4a30b..5b2d52b48d3 100644 --- a/apps/files/tests/BackgroundJob/ScanFilesTest.php +++ b/apps/files/tests/BackgroundJob/ScanFilesTest.php @@ -28,8 +28,8 @@ use OC\Files\Storage\Temporary; use OCA\Files\BackgroundJob\ScanFiles; use OCP\EventDispatcher\IEventDispatcher; use OCP\IConfig; -use OCP\ILogger; use OCP\IUser; +use Psr\Log\LoggerInterface; use Test\TestCase; use Test\Traits\MountProviderTrait; use Test\Traits\UserTrait; @@ -54,7 +54,7 @@ class ScanFilesTest extends TestCase { $config = $this->createMock(IConfig::class); $dispatcher = $this->createMock(IEventDispatcher::class); - $logger = $this->createMock(ILogger::class); + $logger = $this->createMock(LoggerInterface::class); $connection = \OC::$server->getDatabaseConnection(); $this->mountCache = \OC::$server->getUserMountCache(); diff --git a/apps/files_external/lib/Lib/Storage/Swift.php b/apps/files_external/lib/Lib/Storage/Swift.php index 17859259fe3..fb93c6cdce2 100644 --- a/apps/files_external/lib/Lib/Storage/Swift.php +++ b/apps/files_external/lib/Lib/Storage/Swift.php @@ -48,9 +48,9 @@ use Icewind\Streams\IteratorDirectory; use OC\Files\ObjectStore\SwiftFactory; use OCP\Files\IMimeTypeDetector; use OCP\Files\StorageBadConfigException; -use OCP\ILogger; use OpenStack\Common\Error\BadResponseError; use OpenStack\ObjectStore\v1\Models\StorageObject; +use Psr\Log\LoggerInterface; class Swift extends \OC\Files\Storage\Common { /** @var SwiftFactory */ @@ -138,8 +138,8 @@ class Swift extends \OC\Files\Storage\Common { } catch (BadResponseError $e) { // Expected response is "404 Not Found", so only log if it isn't if ($e->getResponse()->getStatusCode() !== 404) { - \OC::$server->getLogger()->logException($e, [ - 'level' => ILogger::ERROR, + \OC::$server->get(LoggerInterface::class)->error($e->getMessage(), [ + 'exception' => $e, 'app' => 'files_external', ]); } @@ -204,7 +204,7 @@ class Swift extends \OC\Files\Storage\Common { $this->connectionFactory = new SwiftFactory( \OC::$server->getMemCacheFactory()->createDistributed('swift/'), $this->params, - \OC::$server->getLogger() + \OC::$server->get(LoggerInterface::class) ); $this->objectStore = new \OC\Files\ObjectStore\Swift($this->params, $this->connectionFactory); $this->bucket = $params['bucket']; @@ -232,8 +232,8 @@ class Swift extends \OC\Files\Storage\Common { // with all properties $this->objectCache->remove($path); } catch (BadResponseError $e) { - \OC::$server->getLogger()->logException($e, [ - 'level' => ILogger::ERROR, + \OC::$server->get(LoggerInterface::class)->error($e->getMessage(), [ + 'exception' => $e, 'app' => 'files_external', ]); return false; @@ -276,8 +276,8 @@ class Swift extends \OC\Files\Storage\Common { $this->objectStore->deleteObject($path . '/'); $this->objectCache->remove($path . '/'); } catch (BadResponseError $e) { - \OC::$server->getLogger()->logException($e, [ - 'level' => ILogger::ERROR, + \OC::$server->get(LoggerInterface::class)->error($e->getMessage(), [ + 'exception' => $e, 'app' => 'files_external', ]); return false; @@ -314,8 +314,8 @@ class Swift extends \OC\Files\Storage\Common { return IteratorDirectory::wrap($files); } catch (\Exception $e) { - \OC::$server->getLogger()->logException($e, [ - 'level' => ILogger::ERROR, + \OC::$server->get(LoggerInterface::class)->error($e->getMessage(), [ + 'exception' => $e, 'app' => 'files_external', ]); return false; @@ -337,8 +337,8 @@ class Swift extends \OC\Files\Storage\Common { return false; } } catch (BadResponseError $e) { - \OC::$server->getLogger()->logException($e, [ - 'level' => ILogger::ERROR, + \OC::$server->get(LoggerInterface::class)->error($e->getMessage(), [ + 'exception' => $e, 'app' => 'files_external', ]); return false; @@ -391,8 +391,8 @@ class Swift extends \OC\Files\Storage\Common { $this->objectCache->remove($path . '/'); } catch (BadResponseError $e) { if ($e->getResponse()->getStatusCode() !== 404) { - \OC::$server->getLogger()->logException($e, [ - 'level' => ILogger::ERROR, + \OC::$server->get(LoggerInterface::class)->error($e->getMessage(), [ + 'exception' => $e, 'app' => 'files_external', ]); throw $e; @@ -415,8 +415,8 @@ class Swift extends \OC\Files\Storage\Common { try { return $this->objectStore->readObject($path); } catch (BadResponseError $e) { - \OC::$server->getLogger()->logException($e, [ - 'level' => ILogger::ERROR, + \OC::$server->get(LoggerInterface::class)->error($e->getMessage(), [ + 'exception' => $e, 'app' => 'files_external', ]); return false; @@ -502,8 +502,8 @@ class Swift extends \OC\Files\Storage\Common { $this->objectCache->remove($path2); $this->objectCache->remove($path2 . '/'); } catch (BadResponseError $e) { - \OC::$server->getLogger()->logException($e, [ - 'level' => ILogger::ERROR, + \OC::$server->get(LoggerInterface::class)->error($e->getMessage(), [ + 'exception' => $e, 'app' => 'files_external', ]); return false; @@ -518,8 +518,8 @@ class Swift extends \OC\Files\Storage\Common { $this->objectCache->remove($path2); $this->objectCache->remove($path2 . '/'); } catch (BadResponseError $e) { - \OC::$server->getLogger()->logException($e, [ - 'level' => ILogger::ERROR, + \OC::$server->get(LoggerInterface::class)->error($e->getMessage(), [ + 'exception' => $e, 'app' => 'files_external', ]); return false; diff --git a/apps/files_sharing/tests/CapabilitiesTest.php b/apps/files_sharing/tests/CapabilitiesTest.php index 01ef13a3e6c..093a04052b1 100644 --- a/apps/files_sharing/tests/CapabilitiesTest.php +++ b/apps/files_sharing/tests/CapabilitiesTest.php @@ -37,7 +37,6 @@ use OCP\Files\Mount\IMountManager; use OCP\IConfig; use OCP\IGroupManager; use OCP\IL10N; -use OCP\ILogger; use OCP\IURLGenerator; use OCP\IUserManager; use OCP\IUserSession; @@ -46,6 +45,7 @@ use OCP\Mail\IMailer; use OCP\Security\IHasher; use OCP\Security\ISecureRandom; use OCP\Share\IProviderFactory; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** @@ -79,7 +79,7 @@ class CapabilitiesTest extends \Test\TestCase { $config = $this->getMockBuilder(IConfig::class)->disableOriginalConstructor()->getMock(); $config->method('getAppValue')->willReturnMap($map); $shareManager = new Manager( - $this->createMock(ILogger::class), + $this->createMock(LoggerInterface::class), $config, $this->createMock(ISecureRandom::class), $this->createMock(IHasher::class), diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php index 6aec2f9821e..4631f9e9d5b 100644 --- a/apps/files_trashbin/lib/Trashbin.php +++ b/apps/files_trashbin/lib/Trashbin.php @@ -60,6 +60,7 @@ use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; use OCP\Lock\ILockingProvider; use OCP\Lock\LockedException; +use Psr\Log\LoggerInterface; class Trashbin { @@ -227,7 +228,7 @@ class Trashbin { ->setValue('user', $query->createNamedParameter($user)); $result = $query->executeStatement(); if (!$result) { - \OC::$server->getLogger()->error('trash bin database couldn\'t be updated for the files owner', ['app' => 'files_trashbin']); + \OC::$server->get(LoggerInterface::class)->error('trash bin database couldn\'t be updated for the files owner', ['app' => 'files_trashbin']); } } } @@ -326,7 +327,7 @@ class Trashbin { if ($trashStorage->file_exists($trashInternalPath)) { $trashStorage->unlink($trashInternalPath); } - \OC::$server->getLogger()->error('Couldn\'t move ' . $file_path . ' to the trash bin', ['app' => 'files_trashbin']); + \OC::$server->get(LoggerInterface::class)->error('Couldn\'t move ' . $file_path . ' to the trash bin', ['app' => 'files_trashbin']); } if ($sourceStorage->file_exists($sourceInternalPath)) { // failed to delete the original file, abort @@ -354,7 +355,7 @@ class Trashbin { ->setValue('user', $query->createNamedParameter($owner)); $result = $query->executeStatement(); if (!$result) { - \OC::$server->getLogger()->error('trash bin database couldn\'t be updated', ['app' => 'files_trashbin']); + \OC::$server->get(LoggerInterface::class)->error('trash bin database couldn\'t be updated', ['app' => 'files_trashbin']); } \OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_moveToTrash', ['filePath' => Filesystem::normalizePath($file_path), 'trashPath' => Filesystem::normalizePath($filename . '.d' . $timestamp)]); @@ -470,7 +471,7 @@ class Trashbin { if ($timestamp) { $location = self::getLocation($user, $filename, $timestamp); if ($location === false) { - \OC::$server->getLogger()->error('trash bin database inconsistent! ($user: ' . $user . ' $filename: ' . $filename . ', $timestamp: ' . $timestamp . ')', ['app' => 'files_trashbin']); + \OC::$server->get(LoggerInterface::class)->error('trash bin database inconsistent! ($user: ' . $user . ' $filename: ' . $filename . ', $timestamp: ' . $timestamp . ')', ['app' => 'files_trashbin']); } else { // if location no longer exists, restore file in the root directory if ($location !== '/' && @@ -870,7 +871,7 @@ class Trashbin { foreach ($files as $file) { if ($availableSpace < 0 && $expiration->isExpired($file['mtime'], true)) { $tmp = self::delete($file['name'], $user, $file['mtime']); - \OC::$server->getLogger()->info('remove "' . $file['name'] . '" (' . $tmp . 'B) to meet the limit of trash bin size (50% of available quota)', ['app' => 'files_trashbin']); + \OC::$server->get(LoggerInterface::class)->info('remove "' . $file['name'] . '" (' . $tmp . 'B) to meet the limit of trash bin size (50% of available quota)', ['app' => 'files_trashbin']); $availableSpace += $tmp; $size += $tmp; } else { @@ -901,9 +902,14 @@ class Trashbin { $size += self::delete($filename, $user, $timestamp); $count++; } catch (\OCP\Files\NotPermittedException $e) { - \OC::$server->getLogger()->logException($e, ['app' => 'files_trashbin', 'level' => \OCP\ILogger::WARN, 'message' => 'Removing "' . $filename . '" from trashbin failed.']); + \OC::$server->get(LoggerInterface::class)->warning('Removing "' . $filename . '" from trashbin failed.', + [ + 'exception' => $e, + 'app' => 'files_trashbin', + ] + ); } - \OC::$server->getLogger()->info( + \OC::$server->get(LoggerInterface::class)->info( 'Remove "' . $filename . '" from trashbin because it exceeds max retention obligation term.', ['app' => 'files_trashbin'] ); @@ -999,7 +1005,7 @@ class Trashbin { $query = new CacheQueryBuilder( \OC::$server->getDatabaseConnection(), \OC::$server->getSystemConfig(), - \OC::$server->getLogger() + \OC::$server->get(LoggerInterface::class) ); $normalizedParentPath = ltrim(Filesystem::normalizePath(dirname('files_trashbin/versions/'. $filename)), '/'); $parentId = $cache->getId($normalizedParentPath); diff --git a/apps/testing/lib/Locking/FakeDBLockingProvider.php b/apps/testing/lib/Locking/FakeDBLockingProvider.php index a8a83812749..5f8ea399477 100644 --- a/apps/testing/lib/Locking/FakeDBLockingProvider.php +++ b/apps/testing/lib/Locking/FakeDBLockingProvider.php @@ -25,7 +25,7 @@ namespace OCA\Testing\Locking; use OCP\AppFramework\Utility\ITimeFactory; use OCP\IDBConnection; -use OCP\ILogger; +use Psr\Log\LoggerInterface; class FakeDBLockingProvider extends \OC\Lock\DBLockingProvider { // Lock for 10 hours just to be sure @@ -37,12 +37,11 @@ class FakeDBLockingProvider extends \OC\Lock\DBLockingProvider { */ protected $db; - /** - * @param \OCP\IDBConnection $connection - * @param \OCP\ILogger $logger - * @param \OCP\AppFramework\Utility\ITimeFactory $timeFactory - */ - public function __construct(IDBConnection $connection, ILogger $logger, ITimeFactory $timeFactory) { + public function __construct( + IDBConnection $connection, + LoggerInterface $logger, + ITimeFactory $timeFactory + ) { parent::__construct($connection, $logger, $timeFactory); $this->db = $connection; } diff --git a/core/Command/Db/ConvertMysqlToMB4.php b/core/Command/Db/ConvertMysqlToMB4.php index 7abd600b3b9..28f7ae6b2fa 100644 --- a/core/Command/Db/ConvertMysqlToMB4.php +++ b/core/Command/Db/ConvertMysqlToMB4.php @@ -30,8 +30,8 @@ use OC\Migration\ConsoleOutput; use OC\Repair\Collation; use OCP\IConfig; use OCP\IDBConnection; -use OCP\ILogger; use OCP\IURLGenerator; +use Psr\Log\LoggerInterface; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -46,16 +46,14 @@ class ConvertMysqlToMB4 extends Command { /** @var IURLGenerator */ private $urlGenerator; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; - /** - * @param IConfig $config - * @param IDBConnection $connection - * @param IURLGenerator $urlGenerator - * @param ILogger $logger - */ - public function __construct(IConfig $config, IDBConnection $connection, IURLGenerator $urlGenerator, ILogger $logger) { + public function __construct( + IConfig $config, + IDBConnection $connection, + IURLGenerator $urlGenerator, + LoggerInterface $logger + ) { $this->config = $config; $this->connection = $connection; $this->urlGenerator = $urlGenerator; diff --git a/core/register_command.php b/core/register_command.php index 5a708510568..6d7831edc0e 100644 --- a/core/register_command.php +++ b/core/register_command.php @@ -104,7 +104,7 @@ if (\OC::$server->getConfig()->getSystemValue('installed', false)) { $application->add(new OC\Core\Command\Config\System\SetConfig(\OC::$server->getSystemConfig())); $application->add(new OC\Core\Command\Db\ConvertType(\OC::$server->getConfig(), new \OC\DB\ConnectionFactory(\OC::$server->getSystemConfig()))); - $application->add(new OC\Core\Command\Db\ConvertMysqlToMB4(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection(), \OC::$server->getURLGenerator(), \OC::$server->getLogger())); + $application->add(new OC\Core\Command\Db\ConvertMysqlToMB4(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection(), \OC::$server->getURLGenerator(), \OC::$server->get(LoggerInterface::class))); $application->add(new OC\Core\Command\Db\ConvertFilecacheBigInt(\OC::$server->get(\OC\DB\Connection::class))); $application->add(new OC\Core\Command\Db\AddMissingIndices(\OC::$server->get(\OC\DB\Connection::class), \OC::$server->getEventDispatcher())); $application->add(new OC\Core\Command\Db\AddMissingColumns(\OC::$server->get(\OC\DB\Connection::class), \OC::$server->getEventDispatcher())); diff --git a/lib/private/DB/Connection.php b/lib/private/DB/Connection.php index 6f89ba64e80..0cd310550b6 100644 --- a/lib/private/DB/Connection.php +++ b/lib/private/DB/Connection.php @@ -49,12 +49,12 @@ use Doctrine\DBAL\Platforms\SqlitePlatform; use Doctrine\DBAL\Result; use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Statement; -use OC\DB\QueryBuilder\QueryBuilder; -use OC\SystemConfig; use OCP\DB\QueryBuilder\IQueryBuilder; -use OCP\ILogger; use OCP\IRequestId; use OCP\PreConditionNotMetException; +use OC\DB\QueryBuilder\QueryBuilder; +use OC\SystemConfig; +use Psr\Log\LoggerInterface; class Connection extends \Doctrine\DBAL\Connection { /** @var string */ @@ -66,8 +66,7 @@ class Connection extends \Doctrine\DBAL\Connection { /** @var SystemConfig */ private $systemConfig; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; protected $lockedTable = null; @@ -78,6 +77,34 @@ class Connection extends \Doctrine\DBAL\Connection { protected $queriesExecuted = 0; /** + * Initializes a new instance of the Connection class. + * + * @throws \Exception + */ + public function __construct( + array $params, + Driver $driver, + ?Configuration $config = null, + ?EventManager $eventManager = null + ) { + if (!isset($params['adapter'])) { + throw new \Exception('adapter not set'); + } + if (!isset($params['tablePrefix'])) { + throw new \Exception('tablePrefix not set'); + } + /** + * @psalm-suppress InternalMethod + */ + parent::__construct($params, $driver, $config, $eventManager); + $this->adapter = new $params['adapter']($this); + $this->tablePrefix = $params['tablePrefix']; + + $this->systemConfig = \OC::$server->getSystemConfig(); + $this->logger = \OC::$server->get(LoggerInterface::class); + } + + /** * @throws Exception */ public function connect() { @@ -126,7 +153,7 @@ class Connection extends \Doctrine\DBAL\Connection { */ public function createQueryBuilder() { $backtrace = $this->getCallerBacktrace(); - \OC::$server->getLogger()->debug('Doctrine QueryBuilder retrieved in {backtrace}', ['app' => 'core', 'backtrace' => $backtrace]); + $this->logger->debug('Doctrine QueryBuilder retrieved in {backtrace}', ['app' => 'core', 'backtrace' => $backtrace]); $this->queriesBuilt++; return parent::createQueryBuilder(); } @@ -139,7 +166,7 @@ class Connection extends \Doctrine\DBAL\Connection { */ public function getExpressionBuilder() { $backtrace = $this->getCallerBacktrace(); - \OC::$server->getLogger()->debug('Doctrine ExpressionBuilder retrieved in {backtrace}', ['app' => 'core', 'backtrace' => $backtrace]); + $this->logger->debug('Doctrine ExpressionBuilder retrieved in {backtrace}', ['app' => 'core', 'backtrace' => $backtrace]); $this->queriesBuilt++; return parent::getExpressionBuilder(); } @@ -169,34 +196,6 @@ class Connection extends \Doctrine\DBAL\Connection { } /** - * Initializes a new instance of the Connection class. - * - * @param array $params The connection parameters. - * @param \Doctrine\DBAL\Driver $driver - * @param \Doctrine\DBAL\Configuration $config - * @param \Doctrine\Common\EventManager $eventManager - * @throws \Exception - */ - public function __construct(array $params, Driver $driver, Configuration $config = null, - EventManager $eventManager = null) { - if (!isset($params['adapter'])) { - throw new \Exception('adapter not set'); - } - if (!isset($params['tablePrefix'])) { - throw new \Exception('tablePrefix not set'); - } - /** - * @psalm-suppress InternalMethod - */ - parent::__construct($params, $driver, $config, $eventManager); - $this->adapter = new $params['adapter']($this); - $this->tablePrefix = $params['tablePrefix']; - - $this->systemConfig = \OC::$server->getSystemConfig(); - $this->logger = \OC::$server->getLogger(); - } - - /** * Prepares an SQL statement. * * @param string $statement The SQL statement to prepare. diff --git a/lib/private/DB/MigrationService.php b/lib/private/DB/MigrationService.php index 5e146112120..a0f905115cc 100644 --- a/lib/private/DB/MigrationService.php +++ b/lib/private/DB/MigrationService.php @@ -43,6 +43,7 @@ use OCP\AppFramework\App; use OCP\AppFramework\QueryException; use OCP\Migration\IMigrationStep; use OCP\Migration\IOutput; +use Psr\Log\LoggerInterface; class MigrationService { @@ -73,7 +74,7 @@ class MigrationService { $this->connection = $connection; $this->output = $output; if (null === $this->output) { - $this->output = new SimpleOutput(\OC::$server->getLogger(), $appName); + $this->output = new SimpleOutput(\OC::$server->get(LoggerInterface::class), $appName); } if ($appName === 'core') { diff --git a/lib/private/DB/QueryBuilder/QueryBuilder.php b/lib/private/DB/QueryBuilder/QueryBuilder.php index de326a2a317..4ecfd773492 100644 --- a/lib/private/DB/QueryBuilder/QueryBuilder.php +++ b/lib/private/DB/QueryBuilder/QueryBuilder.php @@ -53,7 +53,7 @@ use OCP\DB\QueryBuilder\ILiteral; use OCP\DB\QueryBuilder\IParameter; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\DB\QueryBuilder\IQueryFunction; -use OCP\ILogger; +use Psr\Log\LoggerInterface; class QueryBuilder implements IQueryBuilder { @@ -63,8 +63,7 @@ class QueryBuilder implements IQueryBuilder { /** @var SystemConfig */ private $systemConfig; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var \Doctrine\DBAL\Query\QueryBuilder */ private $queryBuilder; @@ -83,9 +82,8 @@ class QueryBuilder implements IQueryBuilder { * * @param ConnectionAdapter $connection * @param SystemConfig $systemConfig - * @param ILogger $logger */ - public function __construct(ConnectionAdapter $connection, SystemConfig $systemConfig, ILogger $logger) { + public function __construct(ConnectionAdapter $connection, SystemConfig $systemConfig, LoggerInterface $logger) { $this->connection = $connection; $this->systemConfig = $systemConfig; $this->logger = $logger; @@ -229,8 +227,7 @@ class QueryBuilder implements IQueryBuilder { } } catch (\Error $e) { // likely an error during conversion of $value to string - $this->logger->debug('DB QueryBuilder: error trying to log SQL query'); - $this->logger->logException($e); + $this->logger->error('DB QueryBuilder: error trying to log SQL query', ['exception' => $e]); } } @@ -245,11 +242,10 @@ class QueryBuilder implements IQueryBuilder { if (empty($hasSelectAll) === empty($hasSelectSpecific)) { $exception = new QueryException('Query is selecting * and specific values in the same query. This is not supported in Oracle.'); - $this->logger->logException($exception, [ - 'message' => 'Query is selecting * and specific values in the same query. This is not supported in Oracle.', + $this->logger->error($exception->getMessage(), [ 'query' => $this->getSQL(), - 'level' => ILogger::ERROR, 'app' => 'core', + 'exception' => $exception, ]); } } @@ -266,21 +262,19 @@ class QueryBuilder implements IQueryBuilder { if ($hasTooLargeArrayParameter) { $exception = new QueryException('More than 1000 expressions in a list are not allowed on Oracle.'); - $this->logger->logException($exception, [ - 'message' => 'More than 1000 expressions in a list are not allowed on Oracle.', + $this->logger->error($exception->getMessage(), [ 'query' => $this->getSQL(), - 'level' => ILogger::ERROR, 'app' => 'core', + 'exception' => $exception, ]); } if ($numberOfParameters > 65535) { $exception = new QueryException('The number of parameters must not exceed 65535. Restriction by PostgreSQL.'); - $this->logger->logException($exception, [ - 'message' => 'The number of parameters must not exceed 65535. Restriction by PostgreSQL.', + $this->logger->error($exception->getMessage(), [ 'query' => $this->getSQL(), - 'level' => ILogger::ERROR, 'app' => 'core', + 'exception' => $exception, ]); } diff --git a/lib/private/Encryption/EncryptionWrapper.php b/lib/private/Encryption/EncryptionWrapper.php index e3dc539dd00..f2803fa5ff8 100644 --- a/lib/private/Encryption/EncryptionWrapper.php +++ b/lib/private/Encryption/EncryptionWrapper.php @@ -30,7 +30,6 @@ use OC\Files\View; use OC\Memcache\ArrayCache; use OCP\Files\Mount\IMountPoint; use OCP\Files\Storage; -use OCP\ILogger; use Psr\Log\LoggerInterface; /** @@ -48,19 +47,14 @@ class EncryptionWrapper { /** @var Manager */ private $manager; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** * EncryptionWrapper constructor. - * - * @param ArrayCache $arrayCache - * @param Manager $manager - * @param ILogger $logger */ public function __construct(ArrayCache $arrayCache, Manager $manager, - ILogger $logger + LoggerInterface $logger ) { $this->arrayCache = $arrayCache; $this->manager = $manager; @@ -101,7 +95,7 @@ class EncryptionWrapper { Filesystem::getMountManager(), $this->manager, $fileHelper, - \OC::$server->get(LoggerInterface::class), + $this->logger, $uid ); return new Encryption( diff --git a/lib/private/Encryption/Manager.php b/lib/private/Encryption/Manager.php index 55578ee25f4..5788da990d5 100644 --- a/lib/private/Encryption/Manager.php +++ b/lib/private/Encryption/Manager.php @@ -34,7 +34,7 @@ use OCP\Encryption\IEncryptionModule; use OCP\Encryption\IManager; use OCP\IConfig; use OCP\IL10N; -use OCP\ILogger; +use Psr\Log\LoggerInterface; class Manager implements IManager { @@ -44,8 +44,7 @@ class Manager implements IManager { /** @var IConfig */ protected $config; - /** @var ILogger */ - protected $logger; + protected LoggerInterface $logger; /** @var Il10n */ protected $l; @@ -59,15 +58,7 @@ class Manager implements IManager { /** @var ArrayCache */ protected $arrayCache; - /** - * @param IConfig $config - * @param ILogger $logger - * @param IL10N $l10n - * @param View $rootView - * @param Util $util - * @param ArrayCache $arrayCache - */ - public function __construct(IConfig $config, ILogger $logger, IL10N $l10n, View $rootView, Util $util, ArrayCache $arrayCache) { + public function __construct(IConfig $config, LoggerInterface $logger, IL10N $l10n, View $rootView, Util $util, ArrayCache $arrayCache) { $this->encryptionModules = []; $this->config = $config; $this->logger = $logger; diff --git a/lib/private/EventDispatcher/GenericEventWrapper.php b/lib/private/EventDispatcher/GenericEventWrapper.php index 3574bc8bb83..b4d851d700f 100644 --- a/lib/private/EventDispatcher/GenericEventWrapper.php +++ b/lib/private/EventDispatcher/GenericEventWrapper.php @@ -26,13 +26,11 @@ declare(strict_types=1); */ namespace OC\EventDispatcher; -use OCP\ILogger; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\GenericEvent; class GenericEventWrapper extends GenericEvent { - - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var GenericEvent */ private $event; @@ -43,7 +41,7 @@ class GenericEventWrapper extends GenericEvent { /** @var bool */ private $deprecationNoticeLogged = false; - public function __construct(ILogger $logger, string $eventName, ?GenericEvent $event) { + public function __construct(LoggerInterface $logger, string $eventName, ?GenericEvent $event) { parent::__construct($eventName); $this->logger = $logger; $this->event = $event; diff --git a/lib/private/EventDispatcher/SymfonyAdapter.php b/lib/private/EventDispatcher/SymfonyAdapter.php index 6cd636afc55..a12e932e380 100644 --- a/lib/private/EventDispatcher/SymfonyAdapter.php +++ b/lib/private/EventDispatcher/SymfonyAdapter.php @@ -27,12 +27,12 @@ declare(strict_types=1); */ namespace OC\EventDispatcher; -use Symfony\Component\EventDispatcher\GenericEvent; -use function is_callable; use OCP\EventDispatcher\Event; -use OCP\ILogger; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Symfony\Component\EventDispatcher\GenericEvent; +use function is_callable; use function is_object; use function is_string; @@ -43,13 +43,12 @@ class SymfonyAdapter implements EventDispatcherInterface { /** @var EventDispatcher */ private $eventDispatcher; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** * @deprecated 20.0.0 */ - public function __construct(EventDispatcher $eventDispatcher, ILogger $logger) { + public function __construct(EventDispatcher $eventDispatcher, LoggerInterface $logger) { $this->eventDispatcher = $eventDispatcher; $this->logger = $logger; } diff --git a/lib/private/Federation/CloudFederationProviderManager.php b/lib/private/Federation/CloudFederationProviderManager.php index c19ca8429ca..c25d4a40363 100644 --- a/lib/private/Federation/CloudFederationProviderManager.php +++ b/lib/private/Federation/CloudFederationProviderManager.php @@ -32,7 +32,7 @@ use OCP\Federation\ICloudFederationProviderManager; use OCP\Federation\ICloudFederationShare; use OCP\Federation\ICloudIdManager; use OCP\Http\Client\IClientService; -use OCP\ILogger; +use Psr\Log\LoggerInterface; /** * Class Manager @@ -55,8 +55,7 @@ class CloudFederationProviderManager implements ICloudFederationProviderManager /** @var ICloudIdManager */ private $cloudIdManager; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var array cache OCM end-points */ private $ocmEndPoints = []; @@ -69,12 +68,11 @@ class CloudFederationProviderManager implements ICloudFederationProviderManager * @param IAppManager $appManager * @param IClientService $httpClientService * @param ICloudIdManager $cloudIdManager - * @param ILogger $logger */ public function __construct(IAppManager $appManager, IClientService $httpClientService, ICloudIdManager $cloudIdManager, - ILogger $logger) { + LoggerInterface $logger) { $this->cloudFederationProvider = []; $this->appManager = $appManager; $this->httpClientService = $httpClientService; @@ -156,7 +154,7 @@ class CloudFederationProviderManager implements ICloudFederationProviderManager // we re-throw the exception and fall back to the old behaviour. // (flat re-shares has been introduced in Nextcloud 9.1) if ($e->getCode() === Http::STATUS_INTERNAL_SERVER_ERROR) { - $this->logger->debug($e->getMessage()); + $this->logger->debug($e->getMessage(), ['exception' => $e]); throw $e; } } @@ -190,7 +188,7 @@ class CloudFederationProviderManager implements ICloudFederationProviderManager } } catch (\Exception $e) { // log the error and return false - $this->logger->error('error while sending notification for federated share: ' . $e->getMessage()); + $this->logger->error('error while sending notification for federated share: ' . $e->getMessage(), ['exception' => $e]); } return false; diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php index 7c2e635549a..949079dfa22 100644 --- a/lib/private/Files/Cache/Cache.php +++ b/lib/private/Files/Cache/Cache.php @@ -58,6 +58,7 @@ use OCP\Files\Search\ISearchOperator; use OCP\Files\Search\ISearchQuery; use OCP\Files\Storage\IStorage; use OCP\IDBConnection; +use Psr\Log\LoggerInterface; /** * Metadata cache for a storage @@ -128,7 +129,7 @@ class Cache implements ICache { return new CacheQueryBuilder( $this->connection, \OC::$server->getSystemConfig(), - \OC::$server->getLogger() + \OC::$server->get(LoggerInterface::class) ); } @@ -590,7 +591,7 @@ class Cache implements ICache { $query = $this->getQueryBuilder(); $query->delete('filecache_extended') ->where($query->expr()->in('fileid', $query->createParameter('childIds'))); - + foreach (array_chunk($childIds, 1000) as $childIdChunk) { $query->setParameter('childIds', $childIdChunk, IQueryBuilder::PARAM_INT_ARRAY); $query->execute(); diff --git a/lib/private/Files/Cache/CacheQueryBuilder.php b/lib/private/Files/Cache/CacheQueryBuilder.php index 87a1f940f20..b5a9101877c 100644 --- a/lib/private/Files/Cache/CacheQueryBuilder.php +++ b/lib/private/Files/Cache/CacheQueryBuilder.php @@ -29,7 +29,7 @@ use OC\DB\QueryBuilder\QueryBuilder; use OC\SystemConfig; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; -use OCP\ILogger; +use Psr\Log\LoggerInterface; /** * Query builder with commonly used helpers for filecache queries @@ -37,7 +37,7 @@ use OCP\ILogger; class CacheQueryBuilder extends QueryBuilder { private $alias = null; - public function __construct(IDBConnection $connection, SystemConfig $systemConfig, ILogger $logger) { + public function __construct(IDBConnection $connection, SystemConfig $systemConfig, LoggerInterface $logger) { parent::__construct($connection, $systemConfig, $logger); } diff --git a/lib/private/Files/Cache/QuerySearchHelper.php b/lib/private/Files/Cache/QuerySearchHelper.php index e065e95e4fd..3bf9abf3524 100644 --- a/lib/private/Files/Cache/QuerySearchHelper.php +++ b/lib/private/Files/Cache/QuerySearchHelper.php @@ -34,7 +34,7 @@ use OCP\Files\IMimeTypeLoader; use OCP\Files\Search\ISearchBinaryOperator; use OCP\Files\Search\ISearchQuery; use OCP\IDBConnection; -use OCP\ILogger; +use Psr\Log\LoggerInterface; class QuerySearchHelper { @@ -44,8 +44,7 @@ class QuerySearchHelper { private $connection; /** @var SystemConfig */ private $systemConfig; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var SearchBuilder */ private $searchBuilder; /** @var QueryOptimizer */ @@ -55,7 +54,7 @@ class QuerySearchHelper { IMimeTypeLoader $mimetypeLoader, IDBConnection $connection, SystemConfig $systemConfig, - ILogger $logger, + LoggerInterface $logger, SearchBuilder $searchBuilder, QueryOptimizer $queryOptimizer ) { diff --git a/lib/private/Files/Config/UserMountCache.php b/lib/private/Files/Config/UserMountCache.php index 9a5eddc4878..666ba9b065b 100644 --- a/lib/private/Files/Config/UserMountCache.php +++ b/lib/private/Files/Config/UserMountCache.php @@ -38,9 +38,9 @@ use OCP\Files\Mount\IMountPoint; use OCP\Files\NotFoundException; use OCP\ICache; use OCP\IDBConnection; -use OCP\ILogger; use OCP\IUser; use OCP\IUserManager; +use Psr\Log\LoggerInterface; /** * Cache mounts points per user in the cache so we can easilly look them up @@ -64,10 +64,7 @@ class UserMountCache implements IUserMountCache { **/ private $mountsForUsers; - /** - * @var ILogger - */ - private $logger; + private LoggerInterface $logger; /** * @var ICache @@ -76,12 +73,8 @@ class UserMountCache implements IUserMountCache { /** * UserMountCache constructor. - * - * @param IDBConnection $connection - * @param IUserManager $userManager - * @param ILogger $logger */ - public function __construct(IDBConnection $connection, IUserManager $userManager, ILogger $logger) { + public function __construct(IDBConnection $connection, IUserManager $userManager, LoggerInterface $logger) { $this->connection = $connection; $this->userManager = $userManager; $this->logger = $logger; diff --git a/lib/private/Files/Mount/ObjectStorePreviewCacheMountProvider.php b/lib/private/Files/Mount/ObjectStorePreviewCacheMountProvider.php index 0043503f2cd..3a20afba5a5 100644 --- a/lib/private/Files/Mount/ObjectStorePreviewCacheMountProvider.php +++ b/lib/private/Files/Mount/ObjectStorePreviewCacheMountProvider.php @@ -31,18 +31,17 @@ use OC\Files\Storage\Wrapper\Jail; use OCP\Files\Config\IRootMountProvider; use OCP\Files\Storage\IStorageFactory; use OCP\IConfig; -use OCP\ILogger; +use Psr\Log\LoggerInterface; /** * Mount provider for object store app data folder for previews */ class ObjectStorePreviewCacheMountProvider implements IRootMountProvider { - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var IConfig */ private $config; - public function __construct(ILogger $logger, IConfig $config) { + public function __construct(LoggerInterface $logger, IConfig $config) { $this->logger = $logger; $this->config = $config; } diff --git a/lib/private/Files/Node/Root.php b/lib/private/Files/Node/Root.php index 53162737b6f..a8b36ee7731 100644 --- a/lib/private/Files/Node/Root.php +++ b/lib/private/Files/Node/Root.php @@ -44,9 +44,9 @@ use OCP\Files\Events\Node\FilesystemTornDownEvent; use OCP\Files\IRootFolder; use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; -use OCP\ILogger; use OCP\IUser; use OCP\IUserManager; +use Psr\Log\LoggerInterface; /** * Class Root @@ -73,7 +73,7 @@ class Root extends Folder implements IRootFolder { private ?IUser $user; private CappedMemoryCache $userFolderCache; private IUserMountCache $userMountCache; - private ILogger $logger; + private LoggerInterface $logger; private IUserManager $userManager; private IEventDispatcher $eventDispatcher; @@ -81,16 +81,13 @@ class Root extends Folder implements IRootFolder { * @param Manager $manager * @param View $view * @param IUser|null $user - * @param IUserMountCache $userMountCache - * @param ILogger $logger - * @param IUserManager $userManager */ public function __construct( $manager, $view, $user, IUserMountCache $userMountCache, - ILogger $logger, + LoggerInterface $logger, IUserManager $userManager, IEventDispatcher $eventDispatcher ) { diff --git a/lib/private/Files/ObjectStore/Swift.php b/lib/private/Files/ObjectStore/Swift.php index a3c8d92f3d2..b463cb9d44d 100644 --- a/lib/private/Files/ObjectStore/Swift.php +++ b/lib/private/Files/ObjectStore/Swift.php @@ -32,6 +32,7 @@ use Icewind\Streams\RetryWrapper; use OCP\Files\NotFoundException; use OCP\Files\ObjectStore\IObjectStore; use OCP\Files\StorageAuthException; +use Psr\Log\LoggerInterface; const SWIFT_SEGMENT_SIZE = 1073741824; // 1GB @@ -48,7 +49,7 @@ class Swift implements IObjectStore { $this->swiftFactory = $connectionFactory ?: new SwiftFactory( \OC::$server->getMemCacheFactory()->createDistributed('swift::'), $params, - \OC::$server->getLogger() + \OC::$server->get(LoggerInterface::class) ); $this->params = $params; } diff --git a/lib/private/Files/ObjectStore/SwiftFactory.php b/lib/private/Files/ObjectStore/SwiftFactory.php index df4b5a93678..bd75ccada2e 100644 --- a/lib/private/Files/ObjectStore/SwiftFactory.php +++ b/lib/private/Files/ObjectStore/SwiftFactory.php @@ -40,7 +40,6 @@ use GuzzleHttp\HandlerStack; use OCP\Files\StorageAuthException; use OCP\Files\StorageNotAvailableException; use OCP\ICache; -use OCP\ILogger; use OpenStack\Common\Auth\Token; use OpenStack\Common\Error\BadResponseError; use OpenStack\Common\Transport\Utils as TransportUtils; @@ -50,13 +49,14 @@ use OpenStack\Identity\v3\Service as IdentityV3Service; use OpenStack\ObjectStore\v1\Models\Container; use OpenStack\OpenStack; use Psr\Http\Message\RequestInterface; +use Psr\Log\LoggerInterface; class SwiftFactory { private $cache; private $params; /** @var Container|null */ private $container = null; - private $logger; + private LoggerInterface $logger; public const DEFAULT_OPTIONS = [ 'autocreate' => false, @@ -65,7 +65,7 @@ class SwiftFactory { 'catalogType' => 'object-store' ]; - public function __construct(ICache $cache, array $params, ILogger $logger) { + public function __construct(ICache $cache, array $params, LoggerInterface $logger) { $this->cache = $cache; $this->params = $params; $this->logger = $logger; @@ -203,7 +203,7 @@ class SwiftFactory { $this->logger->debug('Cached token for swift expired'); } } catch (\Exception $e) { - $this->logger->logException($e); + $this->logger->error($e->getMessage(), ['exception' => $e]); } } } @@ -279,7 +279,7 @@ class SwiftFactory { /** @var RequestInterface $request */ $request = $e->getRequest(); $host = $request->getUri()->getHost() . ':' . $request->getUri()->getPort(); - \OC::$server->getLogger()->error("Can't connect to object storage server at $host"); + $this->logger->error("Can't connect to object storage server at $host", ['exception' => $e]); throw new StorageNotAvailableException("Can't connect to object storage server at $host", StorageNotAvailableException::STATUS_ERROR, $e); } } diff --git a/lib/private/Files/Storage/Wrapper/Encryption.php b/lib/private/Files/Storage/Wrapper/Encryption.php index 75611d1ab0f..4cfe932cc9f 100644 --- a/lib/private/Files/Storage/Wrapper/Encryption.php +++ b/lib/private/Files/Storage/Wrapper/Encryption.php @@ -50,7 +50,7 @@ use OCP\Encryption\Keys\IStorage; use OCP\Files\Cache\ICacheEntry; use OCP\Files\Mount\IMountPoint; use OCP\Files\Storage; -use OCP\ILogger; +use Psr\Log\LoggerInterface; class Encryption extends Wrapper { use LocalTempFileTrait; @@ -64,8 +64,7 @@ class Encryption extends Wrapper { /** @var \OCP\Encryption\IManager */ private $encryptionManager; - /** @var \OCP\ILogger */ - private $logger; + private LoggerInterface $logger; /** @var string */ private $uid; @@ -96,21 +95,12 @@ class Encryption extends Wrapper { /** * @param array $parameters - * @param IManager $encryptionManager - * @param Util $util - * @param ILogger $logger - * @param IFile $fileHelper - * @param string $uid - * @param IStorage $keyStorage - * @param Update $update - * @param Manager $mountManager - * @param ArrayCache $arrayCache */ public function __construct( $parameters, IManager $encryptionManager = null, Util $util = null, - ILogger $logger = null, + LoggerInterface $logger = null, IFile $fileHelper = null, $uid = null, IStorage $keyStorage = null, @@ -448,9 +438,8 @@ class Encryption extends Wrapper { } } } catch (ModuleDoesNotExistsException $e) { - $this->logger->logException($e, [ - 'message' => 'Encryption module "' . $encryptionModuleId . '" not found, file will be stored unencrypted', - 'level' => ILogger::WARN, + $this->logger->warning('Encryption module "' . $encryptionModuleId . '" not found, file will be stored unencrypted', [ + 'exception' => $e, 'app' => 'core', ]); } @@ -503,8 +492,7 @@ class Encryption extends Wrapper { try { $result = $this->fixUnencryptedSize($path, $size, $unencryptedSize); } catch (\Exception $e) { - $this->logger->error('Couldn\'t re-calculate unencrypted size for ' . $path); - $this->logger->logException($e); + $this->logger->error('Couldn\'t re-calculate unencrypted size for ' . $path, ['exception' => $e]); } unset($this->fixUnencryptedSizeOf[$this->getFullPath($path)]); } diff --git a/lib/private/Files/Type/Detection.php b/lib/private/Files/Type/Detection.php index bd2bfb5f939..4cade024460 100644 --- a/lib/private/Files/Type/Detection.php +++ b/lib/private/Files/Type/Detection.php @@ -42,8 +42,8 @@ declare(strict_types=1); namespace OC\Files\Type; use OCP\Files\IMimeTypeDetector; -use OCP\ILogger; use OCP\IURLGenerator; +use Psr\Log\LoggerInterface; /** * Class Detection @@ -66,8 +66,7 @@ class Detection implements IMimeTypeDetector { /** @var IURLGenerator */ private $urlGenerator; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var string */ private $customConfigDir; @@ -75,14 +74,8 @@ class Detection implements IMimeTypeDetector { /** @var string */ private $defaultConfigDir; - /** - * @param IURLGenerator $urlGenerator - * @param ILogger $logger - * @param string $customConfigDir - * @param string $defaultConfigDir - */ public function __construct(IURLGenerator $urlGenerator, - ILogger $logger, + LoggerInterface $logger, string $customConfigDir, string $defaultConfigDir) { $this->urlGenerator = $urlGenerator; diff --git a/lib/private/Files/Utils/Scanner.php b/lib/private/Files/Utils/Scanner.php index 5b633617608..dc220bc710d 100644 --- a/lib/private/Files/Utils/Scanner.php +++ b/lib/private/Files/Utils/Scanner.php @@ -48,7 +48,7 @@ use OCP\Files\NotFoundException; use OCP\Files\Storage\IStorage; use OCP\Files\StorageNotAvailableException; use OCP\IDBConnection; -use OCP\ILogger; +use Psr\Log\LoggerInterface; /** * Class Scanner @@ -71,8 +71,7 @@ class Scanner extends PublicEmitter { /** @var IEventDispatcher */ private $dispatcher; - /** @var ILogger */ - protected $logger; + protected LoggerInterface $logger; /** * Whether to use a DB transaction @@ -92,9 +91,8 @@ class Scanner extends PublicEmitter { * @param string $user * @param IDBConnection|null $db * @param IEventDispatcher $dispatcher - * @param ILogger $logger */ - public function __construct($user, $db, IEventDispatcher $dispatcher, ILogger $logger) { + public function __construct($user, $db, IEventDispatcher $dispatcher, LoggerInterface $logger) { $this->user = $user; $this->db = $db; $this->dispatcher = $dispatcher; @@ -263,8 +261,7 @@ class Scanner extends PublicEmitter { } $propagator->commitBatch(); } catch (StorageNotAvailableException $e) { - $this->logger->error('Storage ' . $storage->getId() . ' not available'); - $this->logger->logException($e); + $this->logger->error('Storage ' . $storage->getId() . ' not available', ['exception' => $e]); $this->emit('\OC\Files\Utils\Scanner', 'StorageNotAvailable', [$e]); } if ($this->useTransaction) { diff --git a/lib/private/Group/Manager.php b/lib/private/Group/Manager.php index e1bd009e79c..28f7a400b41 100644 --- a/lib/private/Group/Manager.php +++ b/lib/private/Group/Manager.php @@ -44,8 +44,8 @@ use OCP\EventDispatcher\IEventDispatcher; use OCP\GroupInterface; use OCP\IGroup; use OCP\IGroupManager; -use OCP\ILogger; use OCP\IUser; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** @@ -71,8 +71,7 @@ class Manager extends PublicEmitter implements IGroupManager { private $userManager; /** @var EventDispatcherInterface */ private $dispatcher; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var \OC\Group\Group[] */ private $cachedGroups = []; @@ -83,14 +82,9 @@ class Manager extends PublicEmitter implements IGroupManager { /** @var \OC\SubAdmin */ private $subAdmin = null; - /** - * @param \OC\User\Manager $userManager - * @param EventDispatcherInterface $dispatcher - * @param ILogger $logger - */ public function __construct(\OC\User\Manager $userManager, EventDispatcherInterface $dispatcher, - ILogger $logger) { + LoggerInterface $logger) { $this->userManager = $userManager; $this->dispatcher = $dispatcher; $this->logger = $logger; diff --git a/lib/private/Http/Client/Client.php b/lib/private/Http/Client/Client.php index 673f566e354..3ba85a2dd9f 100644 --- a/lib/private/Http/Client/Client.php +++ b/lib/private/Http/Client/Client.php @@ -39,7 +39,6 @@ use OCP\Http\Client\IClient; use OCP\Http\Client\IResponse; use OCP\ICertificateManager; use OCP\IConfig; -use OCP\ILogger; /** * Class Client @@ -51,8 +50,6 @@ class Client implements IClient { private $client; /** @var IConfig */ private $config; - /** @var ILogger */ - private $logger; /** @var ICertificateManager */ private $certificateManager; /** @var LocalAddressChecker */ @@ -60,13 +57,11 @@ class Client implements IClient { public function __construct( IConfig $config, - ILogger $logger, ICertificateManager $certificateManager, GuzzleClient $client, LocalAddressChecker $localAddressChecker ) { $this->config = $config; - $this->logger = $logger; $this->client = $client; $this->certificateManager = $certificateManager; $this->localAddressChecker = $localAddressChecker; diff --git a/lib/private/Http/Client/ClientService.php b/lib/private/Http/Client/ClientService.php index d1aed2d7883..e868d4af7a5 100644 --- a/lib/private/Http/Client/ClientService.php +++ b/lib/private/Http/Client/ClientService.php @@ -33,7 +33,6 @@ use OCP\Http\Client\IClient; use OCP\Http\Client\IClientService; use OCP\ICertificateManager; use OCP\IConfig; -use OCP\ILogger; /** * Class ClientService @@ -43,8 +42,6 @@ use OCP\ILogger; class ClientService implements IClientService { /** @var IConfig */ private $config; - /** @var ILogger */ - private $logger; /** @var ICertificateManager */ private $certificateManager; /** @var DnsPinMiddleware */ @@ -53,12 +50,10 @@ class ClientService implements IClientService { private $localAddressChecker; public function __construct(IConfig $config, - ILogger $logger, ICertificateManager $certificateManager, DnsPinMiddleware $dnsPinMiddleware, LocalAddressChecker $localAddressChecker) { $this->config = $config; - $this->logger = $logger; $this->certificateManager = $certificateManager; $this->dnsPinMiddleware = $dnsPinMiddleware; $this->localAddressChecker = $localAddressChecker; @@ -76,7 +71,6 @@ class ClientService implements IClientService { return new Client( $this->config, - $this->logger, $this->certificateManager, $client, $this->localAddressChecker diff --git a/lib/private/Http/Client/LocalAddressChecker.php b/lib/private/Http/Client/LocalAddressChecker.php index c534c5971d1..2789b1b5935 100644 --- a/lib/private/Http/Client/LocalAddressChecker.php +++ b/lib/private/Http/Client/LocalAddressChecker.php @@ -25,14 +25,13 @@ declare(strict_types=1); */ namespace OC\Http\Client; -use OCP\ILogger; use OCP\Http\Client\LocalServerException; +use Psr\Log\LoggerInterface; class LocalAddressChecker { - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; - public function __construct(ILogger $logger) { + public function __construct(LoggerInterface $logger) { $this->logger = $logger; } diff --git a/lib/private/Lock/DBLockingProvider.php b/lib/private/Lock/DBLockingProvider.php index 1ea78d047d2..5eb03ad856b 100644 --- a/lib/private/Lock/DBLockingProvider.php +++ b/lib/private/Lock/DBLockingProvider.php @@ -31,9 +31,9 @@ use OC\DB\QueryBuilder\Literal; use OCP\AppFramework\Utility\ITimeFactory; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; -use OCP\ILogger; use OCP\Lock\ILockingProvider; use OCP\Lock\LockedException; +use Psr\Log\LoggerInterface; /** * Locking provider that stores the locks in the database @@ -44,10 +44,7 @@ class DBLockingProvider extends AbstractLockingProvider { */ private $connection; - /** - * @var \OCP\ILogger - */ - private $logger; + private LoggerInterface $logger; /** * @var \OCP\AppFramework\Utility\ITimeFactory @@ -104,15 +101,11 @@ class DBLockingProvider extends AbstractLockingProvider { } /** - * @param \OCP\IDBConnection $connection - * @param \OCP\ILogger $logger - * @param \OCP\AppFramework\Utility\ITimeFactory $timeFactory - * @param int $ttl * @param bool $cacheSharedLocks */ public function __construct( IDBConnection $connection, - ILogger $logger, + LoggerInterface $logger, ITimeFactory $timeFactory, int $ttl = 3600, $cacheSharedLocks = true diff --git a/lib/private/Mail/Mailer.php b/lib/private/Mail/Mailer.php index 61f506d2676..2f3480498be 100644 --- a/lib/private/Mail/Mailer.php +++ b/lib/private/Mail/Mailer.php @@ -41,7 +41,6 @@ use OCP\Defaults; use OCP\EventDispatcher\IEventDispatcher; use OCP\IConfig; use OCP\IL10N; -use OCP\ILogger; use OCP\IURLGenerator; use OCP\L10N\IFactory; use OCP\Mail\Events\BeforeMessageSent; @@ -49,6 +48,7 @@ use OCP\Mail\IAttachment; use OCP\Mail\IEMailTemplate; use OCP\Mail\IMailer; use OCP\Mail\IMessage; +use Psr\Log\LoggerInterface; /** * Class Mailer provides some basic functions to create a mail message that can be used in combination with @@ -73,8 +73,7 @@ class Mailer implements IMailer { private $instance = null; /** @var IConfig */ private $config; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var Defaults */ private $defaults; /** @var IURLGenerator */ @@ -86,16 +85,8 @@ class Mailer implements IMailer { /** @var IFactory */ private $l10nFactory; - /** - * @param IConfig $config - * @param ILogger $logger - * @param Defaults $defaults - * @param IURLGenerator $urlGenerator - * @param IL10N $l10n - * @param IEventDispatcher $dispatcher - */ public function __construct(IConfig $config, - ILogger $logger, + LoggerInterface $logger, Defaults $defaults, IURLGenerator $urlGenerator, IL10N $l10n, diff --git a/lib/private/Memcache/Factory.php b/lib/private/Memcache/Factory.php index 7791c4beae9..73206aac011 100644 --- a/lib/private/Memcache/Factory.php +++ b/lib/private/Memcache/Factory.php @@ -33,8 +33,8 @@ namespace OC\Memcache; use OCP\ICache; use OCP\ICacheFactory; -use OCP\ILogger; use OCP\IMemcache; +use Psr\Log\LoggerInterface; class Factory implements ICacheFactory { public const NULL_CACHE = NullCache::class; @@ -44,10 +44,7 @@ class Factory implements ICacheFactory { */ private $globalPrefix; - /** - * @var ILogger $logger - */ - private $logger; + private LoggerInterface $logger; /** * @var string $localCacheClass @@ -67,16 +64,14 @@ class Factory implements ICacheFactory { /** @var string */ private $logFile; - /** - * @param string $globalPrefix - * @param ILogger $logger - * @param string|null $localCacheClass - * @param string|null $distributedCacheClass - * @param string|null $lockingCacheClass - * @param string $logFile - */ - public function __construct(string $globalPrefix, ILogger $logger, - $localCacheClass = null, $distributedCacheClass = null, $lockingCacheClass = null, string $logFile = '') { + public function __construct( + string $globalPrefix, + LoggerInterface $logger, + ?string $localCacheClass = null, + ?string $distributedCacheClass = null, + ?string $lockingCacheClass = null, + string $logFile = '' + ) { $this->logger = $logger; $this->logFile = $logFile; $this->globalPrefix = $globalPrefix; diff --git a/lib/private/Migration/SimpleOutput.php b/lib/private/Migration/SimpleOutput.php index 5024fdac585..f97bcb767f8 100644 --- a/lib/private/Migration/SimpleOutput.php +++ b/lib/private/Migration/SimpleOutput.php @@ -21,8 +21,8 @@ */ namespace OC\Migration; -use OCP\ILogger; use OCP\Migration\IOutput; +use Psr\Log\LoggerInterface; /** * Class SimpleOutput @@ -33,12 +33,10 @@ use OCP\Migration\IOutput; * @package OC\Migration */ class SimpleOutput implements IOutput { - - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; private $appName; - public function __construct(ILogger $logger, $appName) { + public function __construct(LoggerInterface $logger, $appName) { $this->logger = $logger; $this->appName = $appName; } diff --git a/lib/private/Repair.php b/lib/private/Repair.php index 677588fa9ee..91bfd47f5de 100644 --- a/lib/private/Repair.php +++ b/lib/private/Repair.php @@ -94,13 +94,12 @@ class Repair implements IOutput { /** @var string */ private $currentStep; - private $logger; + private LoggerInterface $logger; /** * Creates a new repair step runner * * @param IRepairStep[] $repairSteps array of RepairStep instances - * @param EventDispatcherInterface $dispatcher */ public function __construct(array $repairSteps, EventDispatcherInterface $dispatcher, LoggerInterface $logger) { $this->repairSteps = $repairSteps; @@ -172,7 +171,7 @@ class Repair implements IOutput { */ public static function getRepairSteps() { return [ - new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), \OC::$server->getDatabaseConnection(), false), + new Collation(\OC::$server->getConfig(), \OC::$server->get(LoggerInterface::class), \OC::$server->getDatabaseConnection(), false), new RepairMimeTypes(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()), new CleanTags(\OC::$server->getDatabaseConnection(), \OC::$server->getUserManager()), new RepairInvalidShares(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()), @@ -199,7 +198,7 @@ class Repair implements IOutput { new ClearGeneratedAvatarCache(\OC::$server->getConfig(), \OC::$server->query(AvatarManager::class)), new AddPreviewBackgroundCleanupJob(\OC::$server->getJobList()), new AddCleanupUpdaterBackupsJob(\OC::$server->getJobList()), - new CleanupCardDAVPhotoCache(\OC::$server->getConfig(), \OC::$server->getAppDataDir('dav-photocache'), \OC::$server->getLogger()), + new CleanupCardDAVPhotoCache(\OC::$server->getConfig(), \OC::$server->getAppDataDir('dav-photocache'), \OC::$server->get(LoggerInterface::class)), new AddClenupLoginFlowV2BackgroundJob(\OC::$server->getJobList()), new RemoveLinkShares(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig(), \OC::$server->getGroupManager(), \OC::$server->getNotificationManager(), \OC::$server->query(ITimeFactory::class)), new ClearCollectionsAccessCache(\OC::$server->getConfig(), \OC::$server->query(IManager::class)), @@ -240,7 +239,7 @@ class Repair implements IOutput { $connectionAdapter = \OC::$server->get(ConnectionAdapter::class); $config = \OC::$server->getConfig(); $steps = [ - new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), $connectionAdapter, true), + new Collation(\OC::$server->getConfig(), \OC::$server->get(LoggerInterface::class), $connectionAdapter, true), new SqliteAutoincrement($connection), new SaveAccountsTableData($connectionAdapter, $config), new DropAccountTermsTable($connectionAdapter), diff --git a/lib/private/Repair/Collation.php b/lib/private/Repair/Collation.php index e949c261b80..25e85f00af8 100644 --- a/lib/private/Repair/Collation.php +++ b/lib/private/Repair/Collation.php @@ -30,16 +30,15 @@ use Doctrine\DBAL\Exception\DriverException; use Doctrine\DBAL\Platforms\MySQLPlatform; use OCP\IConfig; use OCP\IDBConnection; -use OCP\ILogger; use OCP\Migration\IOutput; use OCP\Migration\IRepairStep; +use Psr\Log\LoggerInterface; class Collation implements IRepairStep { /** @var IConfig */ protected $config; - /** @var ILogger */ - protected $logger; + protected LoggerInterface $logger; /** @var IDBConnection */ protected $connection; @@ -48,12 +47,14 @@ class Collation implements IRepairStep { protected $ignoreFailures; /** - * @param IConfig $config - * @param ILogger $logger - * @param IDBConnection $connection * @param bool $ignoreFailures */ - public function __construct(IConfig $config, ILogger $logger, IDBConnection $connection, $ignoreFailures) { + public function __construct( + IConfig $config, + LoggerInterface $logger, + IDBConnection $connection, + $ignoreFailures + ) { $this->connection = $connection; $this->config = $config; $this->logger = $logger; @@ -83,7 +84,7 @@ class Collation implements IRepairStep { $query->execute(); } catch (DriverException $e) { // Just log this - $this->logger->logException($e); + $this->logger->error($e->getMessage(), ['exception' => $e]); if (!$this->ignoreFailures) { throw $e; } @@ -95,7 +96,7 @@ class Collation implements IRepairStep { $query->execute(); } catch (DriverException $e) { // Just log this - $this->logger->logException($e); + $this->logger->error($e->getMessage(), ['exception' => $e]); if (!$this->ignoreFailures) { throw $e; } diff --git a/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php b/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php index 39b48562791..25dc24fb66c 100644 --- a/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php +++ b/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php @@ -30,9 +30,9 @@ use OCP\Files\IAppData; use OCP\Files\NotFoundException; use OCP\Files\SimpleFS\ISimpleFolder; use OCP\IConfig; -use OCP\ILogger; use OCP\Migration\IOutput; use OCP\Migration\IRepairStep; +use Psr\Log\LoggerInterface; use RuntimeException; /** @@ -52,10 +52,9 @@ class CleanupCardDAVPhotoCache implements IRepairStep { /** @var IAppData */ private $appData; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; - public function __construct(IConfig $config, IAppData $appData, ILogger $logger) { + public function __construct(IConfig $config, IAppData $appData, LoggerInterface $logger) { $this->config = $config; $this->appData = $appData; $this->logger = $logger; @@ -71,7 +70,7 @@ class CleanupCardDAVPhotoCache implements IRepairStep { } catch (NotFoundException $e) { return; } catch (RuntimeException $e) { - $this->logger->logException($e, ['message' => 'Failed to fetch directory listing in CleanupCardDAVPhotoCache']); + $this->logger->error('Failed to fetch directory listing in CleanupCardDAVPhotoCache', ['exception' => $e]); return; } @@ -90,7 +89,7 @@ class CleanupCardDAVPhotoCache implements IRepairStep { /** @var ISimpleFolder $folder */ $folder->getFile('photo.')->delete(); } catch (\Exception $e) { - $this->logger->logException($e); + $this->logger->error($e->getMessage(), ['exception' => $e]); $output->warning('Could not delete file "dav-photocache/' . $folder->getName() . '/photo."'); } } diff --git a/lib/private/Repair/Owncloud/CleanPreviewsBackgroundJob.php b/lib/private/Repair/Owncloud/CleanPreviewsBackgroundJob.php index 67f9d6912d9..7f4bbc35c17 100644 --- a/lib/private/Repair/Owncloud/CleanPreviewsBackgroundJob.php +++ b/lib/private/Repair/Owncloud/CleanPreviewsBackgroundJob.php @@ -29,15 +29,14 @@ use OCP\Files\Folder; use OCP\Files\IRootFolder; use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; -use OCP\ILogger; use OCP\IUserManager; +use Psr\Log\LoggerInterface; class CleanPreviewsBackgroundJob extends QueuedJob { /** @var IRootFolder */ private $rootFolder; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var IJobList */ private $jobList; @@ -50,15 +49,9 @@ class CleanPreviewsBackgroundJob extends QueuedJob { /** * CleanPreviewsBackgroundJob constructor. - * - * @param IRootFolder $rootFolder - * @param ILogger $logger - * @param IJobList $jobList - * @param ITimeFactory $timeFactory - * @param IUserManager $userManager */ public function __construct(IRootFolder $rootFolder, - ILogger $logger, + LoggerInterface $logger, IJobList $jobList, ITimeFactory $timeFactory, IUserManager $userManager) { diff --git a/lib/private/Route/CachingRouter.php b/lib/private/Route/CachingRouter.php index 553ea285fd4..f65060e710b 100644 --- a/lib/private/Route/CachingRouter.php +++ b/lib/private/Route/CachingRouter.php @@ -24,7 +24,7 @@ */ namespace OC\Route; -use OCP\ILogger; +use Psr\Log\LoggerInterface; class CachingRouter extends Router { /** @@ -34,9 +34,8 @@ class CachingRouter extends Router { /** * @param \OCP\ICache $cache - * @param ILogger $logger */ - public function __construct($cache, ILogger $logger) { + public function __construct($cache, LoggerInterface $logger) { $this->cache = $cache; parent::__construct($logger); } diff --git a/lib/private/Route/Router.php b/lib/private/Route/Router.php index fcde8f08897..b957173cacc 100644 --- a/lib/private/Route/Router.php +++ b/lib/private/Route/Router.php @@ -34,9 +34,9 @@ namespace OC\Route; use OC\AppFramework\Routing\RouteParser; use OCP\AppFramework\App; -use OCP\ILogger; use OCP\Route\IRouter; use OCP\Util; +use Psr\Log\LoggerInterface; use Symfony\Component\Routing\Exception\ResourceNotFoundException; use Symfony\Component\Routing\Exception\RouteNotFoundException; use Symfony\Component\Routing\Generator\UrlGenerator; @@ -61,15 +61,11 @@ class Router implements IRouter { protected $loaded = false; /** @var array */ protected $loadedApps = []; - /** @var ILogger */ - protected $logger; + protected LoggerInterface $logger; /** @var RequestContext */ protected $context; - /** - * @param ILogger $logger - */ - public function __construct(ILogger $logger) { + public function __construct(LoggerInterface $logger) { $this->logger = $logger; $baseUrl = \OC::$WEBROOT; if (!(\OC::$server->getConfig()->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) { @@ -364,7 +360,7 @@ class Router implements IRouter { try { return $this->getGenerator()->generate($name, $parameters, $referenceType); } catch (RouteNotFoundException $e) { - $this->logger->logException($e, ['level' => ILogger::INFO]); + $this->logger->info($e->getMessage(), ['exception' => $e]); return ''; } } diff --git a/lib/private/Search/SearchComposer.php b/lib/private/Search/SearchComposer.php index d5f35f504e0..3c228261ec2 100644 --- a/lib/private/Search/SearchComposer.php +++ b/lib/private/Search/SearchComposer.php @@ -28,14 +28,14 @@ declare(strict_types=1); namespace OC\Search; use InvalidArgumentException; -use OC\AppFramework\Bootstrap\Coordinator; use OCP\AppFramework\QueryException; -use OCP\ILogger; use OCP\IServerContainer; use OCP\IUser; use OCP\Search\IProvider; use OCP\Search\ISearchQuery; use OCP\Search\SearchResult; +use OC\AppFramework\Bootstrap\Coordinator; +use Psr\Log\LoggerInterface; use function array_map; /** @@ -68,12 +68,11 @@ class SearchComposer { /** @var IServerContainer */ private $container; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; public function __construct(Coordinator $bootstrapCoordinator, IServerContainer $container, - ILogger $logger) { + LoggerInterface $logger) { $this->container = $container; $this->logger = $logger; $this->bootstrapCoordinator = $bootstrapCoordinator; @@ -99,9 +98,8 @@ class SearchComposer { $this->providers[$provider->getId()] = $provider; } catch (QueryException $e) { // Log an continue. We can be fault tolerant here. - $this->logger->logException($e, [ - 'message' => 'Could not load search provider dynamically: ' . $e->getMessage(), - 'level' => ILogger::ERROR, + $this->logger->error('Could not load search provider dynamically: ' . $e->getMessage(), [ + 'exception' => $e, 'app' => $registration->getAppId(), ]); } diff --git a/lib/private/Security/Bruteforce/Throttler.php b/lib/private/Security/Bruteforce/Throttler.php index abbe77c6637..c47d102b881 100644 --- a/lib/private/Security/Bruteforce/Throttler.php +++ b/lib/private/Security/Bruteforce/Throttler.php @@ -36,8 +36,8 @@ use OC\Security\Normalizer\IpAddress; use OCP\AppFramework\Utility\ITimeFactory; use OCP\IConfig; use OCP\IDBConnection; -use OCP\ILogger; use OCP\Security\Bruteforce\MaxDelayReached; +use Psr\Log\LoggerInterface; /** * Class Throttler implements the bruteforce protection for security actions in @@ -62,22 +62,15 @@ class Throttler { private $db; /** @var ITimeFactory */ private $timeFactory; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var IConfig */ private $config; /** @var bool */ private $hasAttemptsDeleted = false; - /** - * @param IDBConnection $db - * @param ITimeFactory $timeFactory - * @param ILogger $logger - * @param IConfig $config - */ public function __construct(IDBConnection $db, ITimeFactory $timeFactory, - ILogger $logger, + LoggerInterface $logger, IConfig $config) { $this->db = $db; $this->timeFactory = $timeFactory; diff --git a/lib/private/Security/CertificateManager.php b/lib/private/Security/CertificateManager.php index 74ea59c3792..fa26c19ceae 100644 --- a/lib/private/Security/CertificateManager.php +++ b/lib/private/Security/CertificateManager.php @@ -36,8 +36,8 @@ use OC\Files\Filesystem; use OCP\ICertificate; use OCP\ICertificateManager; use OCP\IConfig; -use OCP\ILogger; use OCP\Security\ISecureRandom; +use Psr\Log\LoggerInterface; /** * Manage trusted certificates for users @@ -53,25 +53,16 @@ class CertificateManager implements ICertificateManager { */ protected $config; - /** - * @var ILogger - */ - protected $logger; + protected LoggerInterface $logger; /** @var ISecureRandom */ protected $random; private ?string $bundlePath = null; - /** - * @param \OC\Files\View $view relative to data/ - * @param IConfig $config - * @param ILogger $logger - * @param ISecureRandom $random - */ public function __construct(\OC\Files\View $view, IConfig $config, - ILogger $logger, + LoggerInterface $logger, ISecureRandom $random) { $this->view = $view; $this->config = $config; @@ -147,7 +138,8 @@ class CertificateManager implements ICertificateManager { $defaultCertificates = file_get_contents(\OC::$SERVERROOT . '/resources/config/ca-bundle.crt'); if (strlen($defaultCertificates) < 1024) { // sanity check to verify that we have some content for our bundle // log as exception so we have a stacktrace - $this->logger->logException(new \Exception('Shipped ca-bundle is empty, refusing to create certificate bundle')); + $e = new \Exception('Shipped ca-bundle is empty, refusing to create certificate bundle'); + $this->logger->error($e->getMessage(), ['exception' => $e]); return; } diff --git a/lib/private/Security/IdentityProof/Manager.php b/lib/private/Security/IdentityProof/Manager.php index 0878efeebc7..c92d7390969 100644 --- a/lib/private/Security/IdentityProof/Manager.php +++ b/lib/private/Security/IdentityProof/Manager.php @@ -32,9 +32,9 @@ namespace OC\Security\IdentityProof; use OC\Files\AppData\Factory; use OCP\Files\IAppData; use OCP\IConfig; -use OCP\ILogger; use OCP\IUser; use OCP\Security\ICrypto; +use Psr\Log\LoggerInterface; class Manager { /** @var IAppData */ @@ -43,13 +43,12 @@ class Manager { private $crypto; /** @var IConfig */ private $config; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; public function __construct(Factory $appDataFactory, ICrypto $crypto, IConfig $config, - ILogger $logger + LoggerInterface $logger ) { $this->appData = $appDataFactory->get('identityproof'); $this->crypto = $crypto; diff --git a/lib/private/Server.php b/lib/private/Server.php index b189905cfaf..682e6fa06ce 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -354,7 +354,7 @@ class Server extends ServerContainer implements IServerContainer { ); return new Encryption\Manager( $c->get(\OCP\IConfig::class), - $c->get(ILogger::class), + $c->get(LoggerInterface::class), $c->getL10N('core'), new View(), $util, @@ -428,7 +428,7 @@ class Server extends ServerContainer implements IServerContainer { $view, null, $c->get(IUserMountCache::class), - $this->get(ILogger::class), + $this->get(LoggerInterface::class), $this->get(IUserManager::class), $this->get(IEventDispatcher::class), ); @@ -466,7 +466,11 @@ class Server extends ServerContainer implements IServerContainer { $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class); $this->registerService(\OCP\IGroupManager::class, function (ContainerInterface $c) { - $groupManager = new \OC\Group\Manager($this->get(IUserManager::class), $c->get(SymfonyAdapter::class), $this->get(ILogger::class)); + $groupManager = new \OC\Group\Manager( + $this->get(IUserManager::class), + $c->get(SymfonyAdapter::class), + $this->get(LoggerInterface::class) + ); $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { /** @var IEventDispatcher $dispatcher */ $dispatcher = $this->get(IEventDispatcher::class); @@ -547,7 +551,7 @@ class Server extends ServerContainer implements IServerContainer { $c->get(\OCP\IConfig::class), $c->get(ISecureRandom::class), $c->getLockdownManager(), - $c->get(ILogger::class), + $c->get(LoggerInterface::class), $c->get(IEventDispatcher::class) ); /** @deprecated 21.0.0 use BeforeUserCreatedEvent event with the IEventDispatcher instead */ @@ -687,7 +691,9 @@ class Server extends ServerContainer implements IServerContainer { $this->registerDeprecatedAlias('UserCache', ICache::class); $this->registerService(Factory::class, function (Server $c) { - $arrayCacheFactory = new \OC\Memcache\Factory('', $c->get(ILogger::class), + $arrayCacheFactory = new \OC\Memcache\Factory( + '', + $c->get(LoggerInterface::class), ArrayCache::class, ArrayCache::class, ArrayCache::class @@ -711,7 +717,9 @@ class Server extends ServerContainer implements IServerContainer { $instanceId = \OC_Util::getInstanceId(); $path = \OC::$SERVERROOT; $prefix = md5($instanceId . '-' . $version . '-' . $path); - return new \OC\Memcache\Factory($prefix, $c->get(ILogger::class), + return new \OC\Memcache\Factory( + $prefix, + $c->get(LoggerInterface::class), $config->getSystemValue('memcache.local', null), $config->getSystemValue('memcache.distributed', null), $config->getSystemValue('memcache.locking', null), @@ -792,7 +800,7 @@ class Server extends ServerContainer implements IServerContainer { $this->registerService(Router::class, function (Server $c) { $cacheFactory = $c->get(ICacheFactory::class); - $logger = $c->get(ILogger::class); + $logger = $c->get(LoggerInterface::class); if ($cacheFactory->isLocalCacheAvailable()) { $router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger); } else { @@ -863,7 +871,7 @@ class Server extends ServerContainer implements IServerContainer { $this->registerAlias(IClientService::class, ClientService::class); $this->registerService(LocalAddressChecker::class, function (ContainerInterface $c) { return new LocalAddressChecker( - $c->get(ILogger::class), + $c->get(LoggerInterface::class), ); }); $this->registerService(NegativeDnsCache::class, function (ContainerInterface $c) { @@ -934,7 +942,7 @@ class Server extends ServerContainer implements IServerContainer { $mountCache = new UserMountCache( $c->get(IDBConnection::class), $c->get(IUserManager::class), - $c->get(ILogger::class) + $c->get(LoggerInterface::class) ); $listener = new UserMountCacheListener($mountCache); $listener->listen($c->get(IUserManager::class)); @@ -951,7 +959,7 @@ class Server extends ServerContainer implements IServerContainer { // builtin providers $config = $c->get(\OCP\IConfig::class); - $logger = $c->get(ILogger::class); + $logger = $c->get(LoggerInterface::class); $manager->registerProvider(new CacheMountProvider($config)); $manager->registerHomeProvider(new LocalHomeMountProvider()); $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); @@ -1054,7 +1062,7 @@ class Server extends ServerContainer implements IServerContainer { $this->registerService(IMailer::class, function (Server $c) { return new Mailer( $c->get(\OCP\IConfig::class), - $c->get(ILogger::class), + $c->get(LoggerInterface::class), $c->get(Defaults::class), $c->get(IURLGenerator::class), $c->getL10N('lib'), @@ -1094,7 +1102,7 @@ class Server extends ServerContainer implements IServerContainer { } return new DBLockingProvider( $c->get(IDBConnection::class), - $c->get(ILogger::class), + $c->get(LoggerInterface::class), new TimeFactory(), $ttl, !\OC::$CLI @@ -1117,7 +1125,7 @@ class Server extends ServerContainer implements IServerContainer { $this->registerService(IMimeTypeDetector::class, function (ContainerInterface $c) { return new \OC\Files\Type\Detection( $c->get(IURLGenerator::class), - $c->get(ILogger::class), + $c->get(LoggerInterface::class), \OC::$configDir, \OC::$SERVERROOT . '/resources/config/' ); @@ -1214,7 +1222,7 @@ class Server extends ServerContainer implements IServerContainer { $c->get(IURLGenerator::class), $this->get(ICacheFactory::class), $c->get(SystemConfig::class), - $c->get(ILogger::class) + $c->get(LoggerInterface::class) ); }); $this->registerAlias(\OCP\EventDispatcher\IEventDispatcher::class, \OC\EventDispatcher\EventDispatcher::class); @@ -1263,7 +1271,7 @@ class Server extends ServerContainer implements IServerContainer { $factory = new $factoryClass($this); $manager = new \OC\Share20\Manager( - $c->get(ILogger::class), + $c->get(LoggerInterface::class), $c->get(\OCP\IConfig::class), $c->get(ISecureRandom::class), $c->get(IHasher::class), @@ -1342,7 +1350,7 @@ class Server extends ServerContainer implements IServerContainer { $c->get(IAppManager::class), $c->get(IClientService::class), $c->get(ICloudIdManager::class), - $c->get(ILogger::class) + $c->get(LoggerInterface::class) ); }); @@ -1451,7 +1459,7 @@ class Server extends ServerContainer implements IServerContainer { // Delete avatar on user deletion $dispatcher->addListener('OCP\IUser::preDelete', function (GenericEvent $e) { - $logger = $this->get(ILogger::class); + $logger = $this->get(LoggerInterface::class); $manager = $this->getAvatarManager(); /** @var IUser $user */ $user = $e->getSubject(); @@ -2360,8 +2368,8 @@ class Server extends ServerContainer implements IServerContainer { private function registerDeprecatedAlias(string $alias, string $target) { $this->registerService($alias, function (ContainerInterface $container) use ($target, $alias) { try { - /** @var ILogger $logger */ - $logger = $container->get(ILogger::class); + /** @var LoggerInterface $logger */ + $logger = $container->get(LoggerInterface::class); $logger->debug('The requested alias "' . $alias . '" is deprecated. Please request "' . $target . '" directly. This alias will be removed in a future Nextcloud version.', ['app' => 'serverDI']); } catch (ContainerExceptionInterface $e) { // Could not get logger. Continue diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 2aa4d099024..2a76ddafb25 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -57,7 +57,6 @@ use OCP\HintException; use OCP\IConfig; use OCP\IGroupManager; use OCP\IL10N; -use OCP\ILogger; use OCP\IURLGenerator; use OCP\IUser; use OCP\IUserManager; @@ -75,6 +74,7 @@ use OCP\Share\IManager; use OCP\Share\IProviderFactory; use OCP\Share\IShare; use OCP\Share\IShareProvider; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\GenericEvent; @@ -85,8 +85,7 @@ class Manager implements IManager { /** @var IProviderFactory */ private $factory; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var IConfig */ private $config; /** @var ISecureRandom */ @@ -125,7 +124,7 @@ class Manager implements IManager { private $knownUserService; public function __construct( - ILogger $logger, + LoggerInterface $logger, IConfig $config, ISecureRandom $secureRandom, IHasher $hasher, @@ -951,7 +950,7 @@ class Manager implements IManager { return; } } catch (\Exception $e) { - $this->logger->logException($e, ['message' => 'Share notification mail could not be sent']); + $this->logger->error('Share notification mail could not be sent', ['exception' => $e]); } } diff --git a/lib/private/Template/CSSResourceLocator.php b/lib/private/Template/CSSResourceLocator.php index 9ee11e723e5..a038ba7ce9b 100644 --- a/lib/private/Template/CSSResourceLocator.php +++ b/lib/private/Template/CSSResourceLocator.php @@ -31,7 +31,7 @@ */ namespace OC\Template; -use OCP\ILogger; +use Psr\Log\LoggerInterface; class CSSResourceLocator extends ResourceLocator { @@ -39,13 +39,12 @@ class CSSResourceLocator extends ResourceLocator { protected $scssCacher; /** - * @param ILogger $logger * @param string $theme * @param array $core_map * @param array $party_map * @param SCSSCacher $scssCacher */ - public function __construct(ILogger $logger, $theme, $core_map, $party_map, $scssCacher) { + public function __construct(LoggerInterface $logger, $theme, $core_map, $party_map, $scssCacher) { $this->scssCacher = $scssCacher; parent::__construct($logger, $theme, $core_map, $party_map); diff --git a/lib/private/Template/IconsCacher.php b/lib/private/Template/IconsCacher.php index 01500aa2e9c..c2956d5712a 100644 --- a/lib/private/Template/IconsCacher.php +++ b/lib/private/Template/IconsCacher.php @@ -36,13 +36,11 @@ use OCP\Files\IAppData; use OCP\Files\NotFoundException; use OCP\Files\SimpleFS\ISimpleFile; use OCP\Files\SimpleFS\ISimpleFolder; -use OCP\ILogger; use OCP\IURLGenerator; +use Psr\Log\LoggerInterface; class IconsCacher { - - /** @var ILogger */ - protected $logger; + protected LoggerInterface $logger; /** @var IAppData */ protected $appData; @@ -68,13 +66,9 @@ class IconsCacher { private $cachedList; /** - * @param ILogger $logger - * @param Factory $appDataFactory - * @param IURLGenerator $urlGenerator - * @param ITimeFactory $timeFactory * @throws \OCP\Files\NotPermittedException */ - public function __construct(ILogger $logger, + public function __construct(LoggerInterface $logger, Factory $appDataFactory, IURLGenerator $urlGenerator, ITimeFactory $timeFactory) { diff --git a/lib/private/Template/JSCombiner.php b/lib/private/Template/JSCombiner.php index d2073fbbb83..a6d9f0ee558 100644 --- a/lib/private/Template/JSCombiner.php +++ b/lib/private/Template/JSCombiner.php @@ -33,8 +33,8 @@ use OCP\Files\NotPermittedException; use OCP\Files\SimpleFS\ISimpleFolder; use OCP\ICache; use OCP\ICacheFactory; -use OCP\ILogger; use OCP\IURLGenerator; +use Psr\Log\LoggerInterface; class JSCombiner { @@ -50,24 +50,16 @@ class JSCombiner { /** @var SystemConfig */ protected $config; - /** @var ILogger */ - protected $logger; + protected LoggerInterface $logger; /** @var ICacheFactory */ private $cacheFactory; - /** - * @param IAppData $appData - * @param IURLGenerator $urlGenerator - * @param ICacheFactory $cacheFactory - * @param SystemConfig $config - * @param ILogger $logger - */ public function __construct(IAppData $appData, IURLGenerator $urlGenerator, ICacheFactory $cacheFactory, SystemConfig $config, - ILogger $logger) { + LoggerInterface $logger) { $this->appData = $appData; $this->urlGenerator = $urlGenerator; $this->cacheFactory = $cacheFactory; diff --git a/lib/private/Template/JSResourceLocator.php b/lib/private/Template/JSResourceLocator.php index bf84e1ae958..95ae0d3d832 100644 --- a/lib/private/Template/JSResourceLocator.php +++ b/lib/private/Template/JSResourceLocator.php @@ -27,12 +27,14 @@ */ namespace OC\Template; +use Psr\Log\LoggerInterface; + class JSResourceLocator extends ResourceLocator { /** @var JSCombiner */ protected $jsCombiner; - public function __construct(\OCP\ILogger $logger, $theme, array $core_map, array $party_map, JSCombiner $JSCombiner) { + public function __construct(LoggerInterface $logger, $theme, array $core_map, array $party_map, JSCombiner $JSCombiner) { parent::__construct($logger, $theme, $core_map, $party_map); $this->jsCombiner = $JSCombiner; diff --git a/lib/private/Template/ResourceLocator.php b/lib/private/Template/ResourceLocator.php index 3ca34259907..5a50cc6fd1b 100755 --- a/lib/private/Template/ResourceLocator.php +++ b/lib/private/Template/ResourceLocator.php @@ -29,6 +29,8 @@ */ namespace OC\Template; +use Psr\Log\LoggerInterface; + abstract class ResourceLocator { protected $theme; @@ -39,16 +41,14 @@ abstract class ResourceLocator { protected $resources = []; - /** @var \OCP\ILogger */ - protected $logger; + protected LoggerInterface $logger; /** - * @param \OCP\ILogger $logger * @param string $theme * @param array $core_map * @param array $party_map */ - public function __construct(\OCP\ILogger $logger, $theme, $core_map, $party_map) { + public function __construct(LoggerInterface $logger, $theme, $core_map, $party_map) { $this->logger = $logger; $this->theme = $theme; $this->mapping = $core_map + $party_map; diff --git a/lib/private/Template/SCSSCacher.php b/lib/private/Template/SCSSCacher.php index 536557e7a3d..a552122b358 100644 --- a/lib/private/Template/SCSSCacher.php +++ b/lib/private/Template/SCSSCacher.php @@ -41,16 +41,14 @@ use OCP\Files\SimpleFS\ISimpleFolder; use OCP\ICache; use OCP\ICacheFactory; use OCP\IConfig; -use OCP\ILogger; use OCP\IMemcache; use OCP\IURLGenerator; +use Psr\Log\LoggerInterface; use ScssPhp\ScssPhp\Compiler; use ScssPhp\ScssPhp\OutputStyle; class SCSSCacher { - - /** @var ILogger */ - protected $logger; + protected LoggerInterface $logger; /** @var IAppData */ protected $appData; @@ -91,17 +89,9 @@ class SCSSCacher { private $appConfig; /** - * @param ILogger $logger - * @param Factory $appDataFactory - * @param IURLGenerator $urlGenerator - * @param IConfig $config - * @param \OC_Defaults $defaults * @param string $serverRoot - * @param ICacheFactory $cacheFactory - * @param IconsCacher $iconsCacher - * @param ITimeFactory $timeFactory */ - public function __construct(ILogger $logger, + public function __construct(LoggerInterface $logger, Factory $appDataFactory, IURLGenerator $urlGenerator, IConfig $config, @@ -340,7 +330,7 @@ class SCSSCacher { '@import "functions.scss";' . '@import "' . $fileNameSCSS . '";'); } catch (\Exception $e) { - $this->logger->logException($e, ['app' => 'scss_cacher']); + $this->logger->error($e->getMessage(), ['app' => 'scss_cacher', 'exception' => $e]); return false; } @@ -395,7 +385,7 @@ class SCSSCacher { try { $file->delete(); } catch (NotPermittedException $e) { - $this->logger->logException($e, ['message' => 'SCSSCacher::resetCache unable to delete file: ' . $file->getName(), 'app' => 'scss_cacher']); + $this->logger->error('SCSSCacher::resetCache unable to delete file: ' . $file->getName(), ['exception' => $e, 'app' => 'scss_cacher']); } } } @@ -431,7 +421,7 @@ class SCSSCacher { $scss->compile($variables); $this->injectedVariables = $variables; } catch (\Exception $e) { - $this->logger->logException($e, ['app' => 'scss_cacher']); + $this->logger->error($e->getMessage(), ['exception' => $e, 'app' => 'scss_cacher']); } return $variables; diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php index d7a86ff92bf..cf06f021590 100644 --- a/lib/private/TemplateLayout.php +++ b/lib/private/TemplateLayout.php @@ -57,6 +57,7 @@ use OCP\IUserSession; use OCP\Support\Subscription\IRegistry; use OCP\UserStatus\IManager as IUserStatusManager; use OCP\Util; +use Psr\Log\LoggerInterface; class TemplateLayout extends \OC_Template { private static $versionHash = ''; @@ -345,7 +346,7 @@ class TemplateLayout extends \OC_Template { } $locator = new \OC\Template\CSSResourceLocator( - \OC::$server->getLogger(), + \OC::$server->get(LoggerInterface::class), $theme, [ \OC::$SERVERROOT => \OC::$WEBROOT ], [ \OC::$SERVERROOT => \OC::$WEBROOT ], @@ -380,7 +381,7 @@ class TemplateLayout extends \OC_Template { $theme = \OC_Util::getTheme(); $locator = new \OC\Template\JSResourceLocator( - \OC::$server->getLogger(), + \OC::$server->get(LoggerInterface::class), $theme, [ \OC::$SERVERROOT => \OC::$WEBROOT ], [ \OC::$SERVERROOT => \OC::$WEBROOT ], diff --git a/lib/private/Updater/ChangesCheck.php b/lib/private/Updater/ChangesCheck.php index e3ced6e5b12..e2b66853788 100644 --- a/lib/private/Updater/ChangesCheck.php +++ b/lib/private/Updater/ChangesCheck.php @@ -30,21 +30,20 @@ namespace OC\Updater; use OCP\AppFramework\Db\DoesNotExistException; use OCP\Http\Client\IClientService; use OCP\Http\Client\IResponse; -use OCP\ILogger; +use Psr\Log\LoggerInterface; class ChangesCheck { /** @var IClientService */ protected $clientService; /** @var ChangesMapper */ private $mapper; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; public const RESPONSE_NO_CONTENT = 0; public const RESPONSE_USE_CACHE = 1; public const RESPONSE_HAS_CONTENT = 2; - public function __construct(IClientService $clientService, ChangesMapper $mapper, ILogger $logger) { + public function __construct(IClientService $clientService, ChangesMapper $mapper, LoggerInterface $logger) { $this->clientService = $clientService; $this->mapper = $mapper; $this->logger = $logger; diff --git a/lib/private/User/Session.php b/lib/private/User/Session.php index cd26337cd20..365a01c4595 100644 --- a/lib/private/User/Session.php +++ b/lib/private/User/Session.php @@ -54,7 +54,6 @@ use OCP\AppFramework\Utility\ITimeFactory; use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\NotPermittedException; use OCP\IConfig; -use OCP\ILogger; use OCP\IRequest; use OCP\ISession; use OCP\IUser; @@ -64,6 +63,7 @@ use OCP\Security\ISecureRandom; use OCP\Session\Exceptions\SessionNotAvailableException; use OCP\User\Events\PostLoginEvent; use OCP\Util; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\GenericEvent; /** @@ -114,21 +114,10 @@ class Session implements IUserSession, Emitter { /** @var ILockdownManager */ private $lockdownManager; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var IEventDispatcher */ private $dispatcher; - /** - * @param Manager $manager - * @param ISession $session - * @param ITimeFactory $timeFactory - * @param IProvider|null $tokenProvider - * @param IConfig $config - * @param ISecureRandom $random - * @param ILockdownManager $lockdownManager - * @param ILogger $logger - */ public function __construct(Manager $manager, ISession $session, ITimeFactory $timeFactory, @@ -136,7 +125,7 @@ class Session implements IUserSession, Emitter { IConfig $config, ISecureRandom $random, ILockdownManager $lockdownManager, - ILogger $logger, + LoggerInterface $logger, IEventDispatcher $dispatcher ) { $this->manager = $manager; @@ -533,9 +522,8 @@ class Session implements IUserSession, Emitter { } catch (ExpiredTokenException $e) { throw $e; } catch (InvalidTokenException $ex) { - $this->logger->logException($ex, [ - 'level' => ILogger::DEBUG, - 'message' => 'Token is not valid: ' . $ex->getMessage(), + $this->logger->debug('Token is not valid: ' . $ex->getMessage(), [ + 'exception' => $ex, ]); return false; } @@ -890,7 +878,7 @@ class Session implements IUserSession, Emitter { } catch (SessionNotAvailableException $ex) { return false; } catch (InvalidTokenException $ex) { - \OC::$server->getLogger()->warning('Renewing session token failed', ['app' => 'core']); + $this->logger->warning('Renewing session token failed', ['app' => 'core']); return false; } diff --git a/tests/Test/Repair/Owncloud/CleanPreviewsBackgroundJobTest.php b/tests/Test/Repair/Owncloud/CleanPreviewsBackgroundJobTest.php index a487e021187..8ecef60c35d 100644 --- a/tests/Test/Repair/Owncloud/CleanPreviewsBackgroundJobTest.php +++ b/tests/Test/Repair/Owncloud/CleanPreviewsBackgroundJobTest.php @@ -29,15 +29,15 @@ use OCP\Files\Folder; use OCP\Files\IRootFolder; use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; -use OCP\ILogger; use OCP\IUserManager; +use Psr\Log\LoggerInterface; use Test\TestCase; class CleanPreviewsBackgroundJobTest extends TestCase { /** @var IRootFolder|\PHPUnit_Framework_MockObject_MockObject */ private $rootFolder; - /** @var ILogger|\PHPUnit_Framework_MockObject_MockObject */ + /** @var LoggerInterface|\PHPUnit_Framework_MockObject_MockObject */ private $logger; /** @var IJobList|\PHPUnit_Framework_MockObject_MockObject */ @@ -56,7 +56,7 @@ class CleanPreviewsBackgroundJobTest extends TestCase { parent::setUp(); $this->rootFolder = $this->createMock(IRootFolder::class); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->jobList = $this->createMock(IJobList::class); $this->timeFactory = $this->createMock(ITimeFactory::class); $this->userManager = $this->createMock(IUserManager::class); diff --git a/tests/lib/AppFramework/Routing/RoutingTest.php b/tests/lib/AppFramework/Routing/RoutingTest.php index c53c251ea2d..b4965d61d4f 100644 --- a/tests/lib/AppFramework/Routing/RoutingTest.php +++ b/tests/lib/AppFramework/Routing/RoutingTest.php @@ -6,9 +6,9 @@ use OC\AppFramework\DependencyInjection\DIContainer; use OC\AppFramework\Routing\RouteConfig; use OC\Route\Route; use OC\Route\Router; -use OCP\ILogger; use OCP\Route\IRouter; use PHPUnit\Framework\MockObject\MockObject; +use Psr\Log\LoggerInterface; class RoutingTest extends \Test\TestCase { public function testSimpleRoute() { @@ -133,7 +133,7 @@ class RoutingTest extends \Test\TestCase { /** @var IRouter|MockObject $router */ $router = $this->getMockBuilder(Router::class) ->onlyMethods(['create']) - ->setConstructorArgs([$this->createMock(ILogger::class)]) + ->setConstructorArgs([$this->createMock(LoggerInterface::class)]) ->getMock(); // load route configuration @@ -154,7 +154,7 @@ class RoutingTest extends \Test\TestCase { /** @var IRouter|MockObject $router */ $router = $this->getMockBuilder(Router::class) ->onlyMethods(['create']) - ->setConstructorArgs([$this->createMock(ILogger::class)]) + ->setConstructorArgs([$this->createMock(LoggerInterface::class)]) ->getMock(); // load route configuration @@ -214,7 +214,7 @@ class RoutingTest extends \Test\TestCase { /** @var IRouter|MockObject $router */ $router = $this->getMockBuilder(Router::class) ->onlyMethods(['create']) - ->setConstructorArgs([$this->createMock(ILogger::class)]) + ->setConstructorArgs([$this->createMock(LoggerInterface::class)]) ->getMock(); // we expect create to be called once: @@ -264,7 +264,7 @@ class RoutingTest extends \Test\TestCase { /** @var IRouter|MockObject $router */ $router = $this->getMockBuilder(Router::class) ->onlyMethods(['create']) - ->setConstructorArgs([$this->createMock(ILogger::class)]) + ->setConstructorArgs([$this->createMock(LoggerInterface::class)]) ->getMock(); // we expect create to be called once: @@ -291,7 +291,7 @@ class RoutingTest extends \Test\TestCase { /** @var IRouter|MockObject $router */ $router = $this->getMockBuilder(Router::class) ->onlyMethods(['create']) - ->setConstructorArgs([$this->createMock(ILogger::class)]) + ->setConstructorArgs([$this->createMock(LoggerInterface::class)]) ->getMock(); // route mocks @@ -351,7 +351,7 @@ class RoutingTest extends \Test\TestCase { /** @var IRouter|MockObject $router */ $router = $this->getMockBuilder(Router::class) ->onlyMethods(['create']) - ->setConstructorArgs([$this->createMock(ILogger::class)]) + ->setConstructorArgs([$this->createMock(LoggerInterface::class)]) ->getMock(); // route mocks diff --git a/tests/lib/DB/QueryBuilder/QueryBuilderTest.php b/tests/lib/DB/QueryBuilder/QueryBuilderTest.php index fab080eec86..6e9a7a84925 100644 --- a/tests/lib/DB/QueryBuilder/QueryBuilderTest.php +++ b/tests/lib/DB/QueryBuilder/QueryBuilderTest.php @@ -30,7 +30,7 @@ use OC\DB\QueryBuilder\QueryBuilder; use OC\SystemConfig; use OCP\DB\QueryBuilder\IQueryFunction; use OCP\IDBConnection; -use OCP\ILogger; +use Psr\Log\LoggerInterface; /** * Class QueryBuilderTest @@ -49,7 +49,7 @@ class QueryBuilderTest extends \Test\TestCase { /** @var SystemConfig|\PHPUnit\Framework\MockObject\MockObject */ protected $config; - /** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */ + /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */ protected $logger; protected function setUp(): void { @@ -57,7 +57,7 @@ class QueryBuilderTest extends \Test\TestCase { $this->connection = \OC::$server->getDatabaseConnection(); $this->config = $this->createMock(SystemConfig::class); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->queryBuilder = new QueryBuilder($this->connection, $this->config, $this->logger); } @@ -176,7 +176,7 @@ class QueryBuilderTest extends \Test\TestCase { public function dataSelect() { $config = $this->createMock(SystemConfig::class); - $logger = $this->createMock(ILogger::class); + $logger = $this->createMock(LoggerInterface::class); $queryBuilder = new QueryBuilder(\OC::$server->getDatabaseConnection(), $config, $logger); return [ // select('column1') @@ -244,7 +244,7 @@ class QueryBuilderTest extends \Test\TestCase { public function dataSelectAlias() { $config = $this->createMock(SystemConfig::class); - $logger = $this->createMock(ILogger::class); + $logger = $this->createMock(LoggerInterface::class); $queryBuilder = new QueryBuilder(\OC::$server->getDatabaseConnection(), $config, $logger); return [ ['configvalue', 'cv', ['cv' => '99']], @@ -353,7 +353,7 @@ class QueryBuilderTest extends \Test\TestCase { public function dataAddSelect() { $config = $this->createMock(SystemConfig::class); - $logger = $this->createMock(ILogger::class); + $logger = $this->createMock(LoggerInterface::class); $queryBuilder = new QueryBuilder(\OC::$server->getDatabaseConnection(), $config, $logger); return [ // addSelect('column1') @@ -508,7 +508,7 @@ class QueryBuilderTest extends \Test\TestCase { public function dataFrom() { $config = $this->createMock(SystemConfig::class); - $logger = $this->createMock(ILogger::class); + $logger = $this->createMock(LoggerInterface::class); $qb = new QueryBuilder(\OC::$server->getDatabaseConnection(), $config, $logger); return [ [$qb->createFunction('(' . $qb->select('*')->from('test')->getSQL() . ')'), 'q', null, null, [ @@ -1212,7 +1212,7 @@ class QueryBuilderTest extends \Test\TestCase { public function dataGetTableName() { $config = $this->createMock(SystemConfig::class); - $logger = $this->createMock(ILogger::class); + $logger = $this->createMock(LoggerInterface::class); $qb = new QueryBuilder(\OC::$server->getDatabaseConnection(), $config, $logger); return [ ['*PREFIX*table', null, '`*PREFIX*table`'], @@ -1414,12 +1414,12 @@ class QueryBuilderTest extends \Test\TestCase { ->willReturn($this->createMock(Result::class)); $this->logger ->expects($this->once()) - ->method('logException') - ->willReturnCallback(function ($e, $parameters) { - $this->assertInstanceOf(QueryException::class, $e); + ->method('error') + ->willReturnCallback(function ($message, $parameters) { + $this->assertInstanceOf(QueryException::class, $parameters['exception']); $this->assertSame( 'More than 1000 expressions in a list are not allowed on Oracle.', - $parameters['message'] + $message ); }); $this->config @@ -1449,12 +1449,12 @@ class QueryBuilderTest extends \Test\TestCase { ->willReturn($this->createMock(Result::class)); $this->logger ->expects($this->once()) - ->method('logException') - ->willReturnCallback(function ($e, $parameters) { - $this->assertInstanceOf(QueryException::class, $e); + ->method('error') + ->willReturnCallback(function ($message, $parameters) { + $this->assertInstanceOf(QueryException::class, $parameters['exception']); $this->assertSame( 'The number of parameters must not exceed 65535. Restriction by PostgreSQL.', - $parameters['message'] + $message ); }); $this->config diff --git a/tests/lib/Encryption/EncryptionWrapperTest.php b/tests/lib/Encryption/EncryptionWrapperTest.php index 20bcb6e7ca1..5d707ca6ec6 100644 --- a/tests/lib/Encryption/EncryptionWrapperTest.php +++ b/tests/lib/Encryption/EncryptionWrapperTest.php @@ -25,7 +25,7 @@ use OC\Encryption\EncryptionWrapper; use OC\Encryption\Manager; use OC\Memcache\ArrayCache; use OCP\Files\Storage; -use OCP\ILogger; +use Psr\Log\LoggerInterface; use Test\TestCase; class EncryptionWrapperTest extends TestCase { @@ -33,7 +33,7 @@ class EncryptionWrapperTest extends TestCase { /** @var EncryptionWrapper */ private $instance; - /** @var \PHPUnit\Framework\MockObject\MockObject | \OCP\ILogger */ + /** @var \PHPUnit\Framework\MockObject\MockObject | LoggerInterface */ private $logger; /** @var \PHPUnit\Framework\MockObject\MockObject | \OC\Encryption\Manager */ @@ -47,8 +47,7 @@ class EncryptionWrapperTest extends TestCase { $this->arrayCache = $this->createMock(ArrayCache::class); $this->manager = $this->createMock(Manager::class); - $this->logger = $this->createMock(ILogger::class); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->instance = new EncryptionWrapper($this->arrayCache, $this->manager, $this->logger); } diff --git a/tests/lib/Encryption/ManagerTest.php b/tests/lib/Encryption/ManagerTest.php index 81ac263cb93..00448db87d6 100644 --- a/tests/lib/Encryption/ManagerTest.php +++ b/tests/lib/Encryption/ManagerTest.php @@ -9,7 +9,7 @@ use OC\Memcache\ArrayCache; use OCP\Encryption\IEncryptionModule; use OCP\IConfig; use OCP\IL10N; -use OCP\ILogger; +use Psr\Log\LoggerInterface; use Test\TestCase; class ManagerTest extends TestCase { @@ -20,7 +20,7 @@ class ManagerTest extends TestCase { /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */ private $config; - /** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */ + /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */ private $logger; /** @var IL10N|\PHPUnit\Framework\MockObject\MockObject */ @@ -38,7 +38,7 @@ class ManagerTest extends TestCase { protected function setUp(): void { parent::setUp(); $this->config = $this->createMock(IConfig::class); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->l10n = $this->createMock(IL10N::class); $this->view = $this->createMock(View::class); $this->util = $this->createMock(Util::class); diff --git a/tests/lib/EventDispatcher/SymfonyAdapterTest.php b/tests/lib/EventDispatcher/SymfonyAdapterTest.php index 5e2803624af..785b4bfdfcb 100644 --- a/tests/lib/EventDispatcher/SymfonyAdapterTest.php +++ b/tests/lib/EventDispatcher/SymfonyAdapterTest.php @@ -30,8 +30,8 @@ use OC\EventDispatcher\GenericEventWrapper; use OC\EventDispatcher\SymfonyAdapter; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\GenericEvent; -use OCP\ILogger; use PHPUnit\Framework\MockObject\MockObject; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\Event as SymfonyEvent; use Symfony\Component\EventDispatcher\EventDispatcher as SymfonyDispatcher; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -43,7 +43,7 @@ class SymfonyAdapterTest extends TestCase { /** @var EventDispatcher|MockObject */ private $eventDispatcher; - /** @var ILogger|MockObject */ + /** @var LoggerInterface|MockObject */ private $logger; /** @var EventDispatcherInterface */ @@ -53,7 +53,7 @@ class SymfonyAdapterTest extends TestCase { parent::setUp(); $this->eventDispatcher = $this->createMock(EventDispatcher::class); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->adapter = new SymfonyAdapter( $this->eventDispatcher, diff --git a/tests/lib/Files/Config/UserMountCacheTest.php b/tests/lib/Files/Config/UserMountCacheTest.php index 0922dab3672..f4c6a427abd 100644 --- a/tests/lib/Files/Config/UserMountCacheTest.php +++ b/tests/lib/Files/Config/UserMountCacheTest.php @@ -11,7 +11,6 @@ namespace Test\Files\Config; use OC\DB\QueryBuilder\Literal; use OC\Files\Mount\MountPoint; use OC\Files\Storage\Storage; -use OC\Log; use OC\User\Manager; use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\Config\ICachedMountInfo; @@ -19,6 +18,7 @@ use OCP\ICacheFactory; use OCP\IConfig; use OCP\IDBConnection; use OCP\IUserManager; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Test\TestCase; use Test\Util\User\Dummy; @@ -66,7 +66,7 @@ class UserMountCacheTest extends TestCase { $userBackend->createUser('u2', ''); $userBackend->createUser('u3', ''); $this->userManager->registerBackend($userBackend); - $this->cache = new \OC\Files\Config\UserMountCache($this->connection, $this->userManager, $this->createMock(Log::class)); + $this->cache = new \OC\Files\Config\UserMountCache($this->connection, $this->userManager, $this->createMock(LoggerInterface::class)); } protected function tearDown(): void { diff --git a/tests/lib/Files/EtagTest.php b/tests/lib/Files/EtagTest.php index 39069ce4dfe..43b92c12391 100644 --- a/tests/lib/Files/EtagTest.php +++ b/tests/lib/Files/EtagTest.php @@ -11,6 +11,7 @@ namespace Test\Files; use OC\Files\Filesystem; use OCP\EventDispatcher\IEventDispatcher; use OCA\Files_Sharing\AppInfo\Application; +use Psr\Log\LoggerInterface; /** * Class EtagTest @@ -69,7 +70,7 @@ class EtagTest extends \Test\TestCase { $files = ['/foo.txt', '/folder/bar.txt', '/folder/subfolder', '/folder/subfolder/qwerty.txt']; $originalEtags = $this->getEtags($files); - $scanner = new \OC\Files\Utils\Scanner($user1, \OC::$server->getDatabaseConnection(), \OC::$server->query(IEventDispatcher::class), \OC::$server->getLogger()); + $scanner = new \OC\Files\Utils\Scanner($user1, \OC::$server->getDatabaseConnection(), \OC::$server->query(IEventDispatcher::class), \OC::$server->get(LoggerInterface::class)); $scanner->backgroundScan('/'); $newEtags = $this->getEtags($files); diff --git a/tests/lib/Files/Mount/ObjectStorePreviewCacheMountProviderTest.php b/tests/lib/Files/Mount/ObjectStorePreviewCacheMountProviderTest.php index 400808d7cd5..ef2ede729ce 100644 --- a/tests/lib/Files/Mount/ObjectStorePreviewCacheMountProviderTest.php +++ b/tests/lib/Files/Mount/ObjectStorePreviewCacheMountProviderTest.php @@ -30,8 +30,8 @@ use OC\Files\ObjectStore\S3; use OC\Files\Storage\StorageFactory; use OCP\Files\Storage\IStorageFactory; use OCP\IConfig; -use OCP\ILogger; use PHPUnit\Framework\MockObject\MockObject; +use Psr\Log\LoggerInterface; /** * @group DB @@ -43,7 +43,7 @@ class ObjectStorePreviewCacheMountProviderTest extends \Test\TestCase { /** @var ObjectStorePreviewCacheMountProvider */ protected $provider; - /** @var ILogger|MockObject */ + /** @var LoggerInterface|MockObject */ protected $logger; /** @var IConfig|MockObject */ protected $config; @@ -54,7 +54,7 @@ class ObjectStorePreviewCacheMountProviderTest extends \Test\TestCase { protected function setUp(): void { parent::setUp(); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->config = $this->createMock(IConfig::class); $this->loader = $this->createMock(StorageFactory::class); diff --git a/tests/lib/Files/Node/HookConnectorTest.php b/tests/lib/Files/Node/HookConnectorTest.php index 5e0b4017243..f99db6599fd 100644 --- a/tests/lib/Files/Node/HookConnectorTest.php +++ b/tests/lib/Files/Node/HookConnectorTest.php @@ -30,9 +30,9 @@ use OCP\Files\Events\Node\NodeRenamedEvent; use OCP\Files\Events\Node\NodeTouchedEvent; use OCP\Files\Events\Node\NodeWrittenEvent; use OCP\Files\Node; -use OCP\ILogger; use OCP\IUserManager; use PHPUnit\Framework\MockObject\MockObject; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\GenericEvent; use Test\TestCase; @@ -77,7 +77,7 @@ class HookConnectorTest extends TestCase { $this->view, \OC::$server->getUserManager()->get($this->userId), \OC::$server->getUserMountCache(), - $this->createMock(ILogger::class), + $this->createMock(LoggerInterface::class), $this->createMock(IUserManager::class), $this->createMock(IEventDispatcher::class) ); diff --git a/tests/lib/Files/Node/IntegrationTest.php b/tests/lib/Files/Node/IntegrationTest.php index 71e8793ad6f..5ef5a134e1b 100644 --- a/tests/lib/Files/Node/IntegrationTest.php +++ b/tests/lib/Files/Node/IntegrationTest.php @@ -13,8 +13,8 @@ use OC\Files\Storage\Temporary; use OC\Files\View; use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\Mount\IMountManager; -use OCP\ILogger; use OCP\IUserManager; +use Psr\Log\LoggerInterface; use Test\Traits\UserTrait; /** @@ -59,7 +59,7 @@ class IntegrationTest extends \Test\TestCase { $this->view, $user, \OC::$server->getUserMountCache(), - $this->createMock(ILogger::class), + $this->createMock(LoggerInterface::class), $this->createMock(IUserManager::class), $this->createMock(IEventDispatcher::class) ); diff --git a/tests/lib/Files/Node/NodeTest.php b/tests/lib/Files/Node/NodeTest.php index a60a20b99f3..cc936baacb0 100644 --- a/tests/lib/Files/Node/NodeTest.php +++ b/tests/lib/Files/Node/NodeTest.php @@ -16,9 +16,9 @@ use OCP\Files\IRootFolder; use OCP\Files\Node; use OCP\Files\NotFoundException; use OCP\Files\Storage; -use OCP\ILogger; use OCP\IUser; use OCP\IUserManager; +use Psr\Log\LoggerInterface; /** * Class NodeTest @@ -36,7 +36,7 @@ abstract class NodeTest extends \Test\TestCase { protected $root; /** @var \OCP\Files\Config\IUserMountCache|\PHPUnit\Framework\MockObject\MockObject */ protected $userMountCache; - /** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */ + /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */ protected $logger; /** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */ protected $userManager; @@ -56,7 +56,7 @@ abstract class NodeTest extends \Test\TestCase { $this->userMountCache = $this->getMockBuilder('\OCP\Files\Config\IUserMountCache') ->disableOriginalConstructor() ->getMock(); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->userManager = $this->createMock(IUserManager::class); $this->eventDispatcher = $this->createMock(IEventDispatcher::class); $this->root = $this->getMockBuilder('\OC\Files\Node\Root') diff --git a/tests/lib/Files/Node/RootTest.php b/tests/lib/Files/Node/RootTest.php index a7f7dc02e01..fe151d70dc3 100644 --- a/tests/lib/Files/Node/RootTest.php +++ b/tests/lib/Files/Node/RootTest.php @@ -14,9 +14,9 @@ use OC\Files\Mount\Manager; use OC\Files\Node\Folder; use OC\Files\View; use OCP\EventDispatcher\IEventDispatcher; -use OCP\ILogger; use OCP\IUser; use OCP\IUserManager; +use Psr\Log\LoggerInterface; /** * Class RootTest @@ -30,7 +30,7 @@ class RootTest extends \Test\TestCase { private $manager; /** @var \OCP\Files\Config\IUserMountCache|\PHPUnit\Framework\MockObject\MockObject */ private $userMountCache; - /** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */ + /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */ private $logger; /** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */ private $userManager; @@ -47,7 +47,7 @@ class RootTest extends \Test\TestCase { $this->userMountCache = $this->getMockBuilder('\OCP\Files\Config\IUserMountCache') ->disableOriginalConstructor() ->getMock(); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->userManager = $this->createMock(IUserManager::class); $this->eventDispatcher = $this->createMock(IEventDispatcher::class); } diff --git a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php index 71af8fb7ece..d26e5c499e7 100644 --- a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php +++ b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php @@ -8,7 +8,6 @@ use OC\Encryption\Util; use OC\Files\Storage\Temporary; use OC\Files\Storage\Wrapper\Encryption; use OC\Files\View; -use OC\Log; use OC\Memcache\ArrayCache; use OC\User\Manager; use OCP\Encryption\IEncryptionModule; @@ -19,7 +18,7 @@ use OCP\Files\Cache\ICache; use OCP\Files\Mount\IMountPoint; use OCP\ICacheFactory; use OCP\IConfig; -use OCP\ILogger; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Test\Files\Storage\Storage; @@ -151,7 +150,7 @@ class EncryptionTest extends Storage { ->getMock(); $this->file->expects($this->any())->method('getAccessList')->willReturn([]); - $this->logger = $this->createMock(Log::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->sourceStorage = new Temporary([]); @@ -584,7 +583,7 @@ class EncryptionTest extends Storage { $this->arrayCache ] )->getMock(); - + $cache = $this->getMockBuilder('\OC\Files\Cache\Cache') ->disableOriginalConstructor()->getMock(); $cache->expects($this->any()) @@ -607,9 +606,9 @@ class EncryptionTest extends Storage { ) ->setMethods(['getCache','readFirstBlock', 'parseRawHeader']) ->getMock(); - + $instance->expects($this->once())->method('getCache')->willReturn($cache); - + $instance->expects($this->once())->method(('parseRawHeader')) ->willReturn([Util::HEADER_ENCRYPTION_MODULE_KEY => 'OC_DEFAULT_MODULE']); @@ -989,7 +988,6 @@ class EncryptionTest extends Storage { ) { $encryptionManager = $this->createMock(\OC\Encryption\Manager::class); $util = $this->createMock(Util::class); - $logger = $this->createMock(ILogger::class); $fileHelper = $this->createMock(IFile::class); $uid = null; $keyStorage = $this->createMock(IStorage::class); @@ -1007,7 +1005,7 @@ class EncryptionTest extends Storage { ['mountPoint' => '', 'mount' => $mount, 'storage' => ''], $encryptionManager, $util, - $logger, + $this->logger, $fileHelper, $uid, $keyStorage, diff --git a/tests/lib/Files/Type/DetectionTest.php b/tests/lib/Files/Type/DetectionTest.php index a7ac6c8057d..568dbb0cf56 100644 --- a/tests/lib/Files/Type/DetectionTest.php +++ b/tests/lib/Files/Type/DetectionTest.php @@ -22,8 +22,8 @@ namespace Test\Files\Type; use OC\Files\Type\Detection; -use OCP\ILogger; use OCP\IURLGenerator; +use Psr\Log\LoggerInterface; class DetectionTest extends \Test\TestCase { /** @var Detection */ @@ -33,7 +33,7 @@ class DetectionTest extends \Test\TestCase { parent::setUp(); $this->detection = new Detection( \OC::$server->getURLGenerator(), - \OC::$server->getLogger(), + \OC::$server->get(LoggerInterface::class), \OC::$SERVERROOT . '/config/', \OC::$SERVERROOT . '/resources/config/' ); @@ -151,8 +151,8 @@ class DetectionTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); - /** @var ILogger $logger */ - $logger = $this->createMock(ILogger::class); + /** @var LoggerInterface $logger */ + $logger = $this->createMock(LoggerInterface::class); //Only call the url generator once $urlGenerator->expects($this->once()) diff --git a/tests/lib/Files/Utils/ScannerTest.php b/tests/lib/Files/Utils/ScannerTest.php index 414d38bae06..eb0b9938886 100644 --- a/tests/lib/Files/Utils/ScannerTest.php +++ b/tests/lib/Files/Utils/ScannerTest.php @@ -15,6 +15,7 @@ use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\Config\IMountProvider; use OCP\Files\Storage\IStorageFactory; use OCP\IUser; +use Psr\Log\LoggerInterface; class TestScanner extends \OC\Files\Utils\Scanner { /** @@ -71,7 +72,7 @@ class ScannerTest extends \Test\TestCase { $storage->file_put_contents('foo.txt', 'qwerty'); $storage->file_put_contents('folder/bar.txt', 'qwerty'); - $scanner = new TestScanner('', \OC::$server->getDatabaseConnection(), $this->createMock(IEventDispatcher::class), \OC::$server->getLogger()); + $scanner = new TestScanner('', \OC::$server->getDatabaseConnection(), $this->createMock(IEventDispatcher::class), \OC::$server->get(LoggerInterface::class)); $scanner->addMount($mount); $scanner->scan(''); @@ -93,7 +94,7 @@ class ScannerTest extends \Test\TestCase { $storage->file_put_contents('foo.txt', 'qwerty'); $storage->file_put_contents('folder/bar.txt', 'qwerty'); - $scanner = new TestScanner('', \OC::$server->getDatabaseConnection(), $this->createMock(IEventDispatcher::class), \OC::$server->getLogger()); + $scanner = new TestScanner('', \OC::$server->getDatabaseConnection(), $this->createMock(IEventDispatcher::class), \OC::$server->get(LoggerInterface::class)); $scanner->addMount($mount); $scanner->scan(''); @@ -131,7 +132,7 @@ class ScannerTest extends \Test\TestCase { $storage->file_put_contents('foo.txt', 'qwerty'); $storage->file_put_contents('folder/bar.txt', 'qwerty'); - $scanner = new \OC\Files\Utils\Scanner($uid, \OC::$server->getDatabaseConnection(), \OC::$server->query(IEventDispatcher::class), \OC::$server->getLogger()); + $scanner = new \OC\Files\Utils\Scanner($uid, \OC::$server->getDatabaseConnection(), \OC::$server->query(IEventDispatcher::class), \OC::$server->get(LoggerInterface::class)); $this->assertFalse($cache->inCache('folder/bar.txt')); $scanner->scan('/' . $uid . '/files/foo'); @@ -163,7 +164,7 @@ class ScannerTest extends \Test\TestCase { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid path to scan'); - $scanner = new TestScanner('', \OC::$server->getDatabaseConnection(), $this->createMock(IEventDispatcher::class), \OC::$server->getLogger()); + $scanner = new TestScanner('', \OC::$server->getDatabaseConnection(), $this->createMock(IEventDispatcher::class), \OC::$server->get(LoggerInterface::class)); $scanner->scan($invalidPath); } @@ -177,7 +178,7 @@ class ScannerTest extends \Test\TestCase { $storage->file_put_contents('folder/bar.txt', 'qwerty'); $storage->touch('folder/bar.txt', time() - 200); - $scanner = new TestScanner('', \OC::$server->getDatabaseConnection(), $this->createMock(IEventDispatcher::class), \OC::$server->getLogger()); + $scanner = new TestScanner('', \OC::$server->getDatabaseConnection(), $this->createMock(IEventDispatcher::class), \OC::$server->get(LoggerInterface::class)); $scanner->addMount($mount); $scanner->scan(''); @@ -203,7 +204,7 @@ class ScannerTest extends \Test\TestCase { $storage->file_put_contents('folder/bar.txt', 'qwerty'); $storage->file_put_contents('folder/subfolder/foobar.txt', 'qwerty'); - $scanner = new TestScanner('', \OC::$server->getDatabaseConnection(), $this->createMock(IEventDispatcher::class), \OC::$server->getLogger()); + $scanner = new TestScanner('', \OC::$server->getDatabaseConnection(), $this->createMock(IEventDispatcher::class), \OC::$server->get(LoggerInterface::class)); $scanner->addMount($mount); $scanner->scan('', $recusive = false); diff --git a/tests/lib/Group/ManagerTest.php b/tests/lib/Group/ManagerTest.php index dfe21b825f7..d689fd4eb7a 100644 --- a/tests/lib/Group/ManagerTest.php +++ b/tests/lib/Group/ManagerTest.php @@ -26,9 +26,9 @@ namespace Test\Group; use OC\Group\Database; use OC\User\Manager; use OCP\GroupInterface; -use OCP\ILogger; use OCP\IUser; use PHPUnit\Framework\MockObject\MockObject; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Test\TestCase; @@ -37,7 +37,7 @@ class ManagerTest extends TestCase { protected $userManager; /** @var EventDispatcherInterface|MockObject */ protected $dispatcher; - /** @var ILogger|MockObject */ + /** @var LoggerInterface|MockObject */ protected $logger; protected function setUp(): void { @@ -45,7 +45,7 @@ class ManagerTest extends TestCase { $this->userManager = $this->createMock(Manager::class); $this->dispatcher = $this->createMock(EventDispatcherInterface::class); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); } private function getTestUser($userId) { diff --git a/tests/lib/Http/Client/ClientServiceTest.php b/tests/lib/Http/Client/ClientServiceTest.php index f529e25966e..94f4d51ecee 100644 --- a/tests/lib/Http/Client/ClientServiceTest.php +++ b/tests/lib/Http/Client/ClientServiceTest.php @@ -17,7 +17,6 @@ use OC\Http\Client\DnsPinMiddleware; use OC\Http\Client\LocalAddressChecker; use OCP\ICertificateManager; use OCP\IConfig; -use OCP\ILogger; /** * Class ClientServiceTest @@ -28,7 +27,6 @@ class ClientServiceTest extends \Test\TestCase { $config = $this->createMock(IConfig::class); /** @var ICertificateManager $certificateManager */ $certificateManager = $this->createMock(ICertificateManager::class); - $logger = $this->createMock(ILogger::class); $dnsPinMiddleware = $this->createMock(DnsPinMiddleware::class); $dnsPinMiddleware ->expects($this->atLeastOnce()) @@ -39,7 +37,6 @@ class ClientServiceTest extends \Test\TestCase { $clientService = new ClientService( $config, - $logger, $certificateManager, $dnsPinMiddleware, $localAddressChecker @@ -53,7 +50,6 @@ class ClientServiceTest extends \Test\TestCase { $this->assertEquals( new Client( $config, - $logger, $certificateManager, $guzzleClient, $localAddressChecker diff --git a/tests/lib/Http/Client/ClientTest.php b/tests/lib/Http/Client/ClientTest.php index 395e82b8a4c..63835a4d4cd 100644 --- a/tests/lib/Http/Client/ClientTest.php +++ b/tests/lib/Http/Client/ClientTest.php @@ -15,7 +15,6 @@ use OC\Security\CertificateManager; use OCP\Http\Client\LocalServerException; use OCP\ICertificateManager; use OCP\IConfig; -use OCP\ILogger; use PHPUnit\Framework\MockObject\MockObject; /** @@ -30,8 +29,6 @@ class ClientTest extends \Test\TestCase { private $client; /** @var IConfig|MockObject */ private $config; - /** @var ILogger|MockObject */ - private $logger; /** @var LocalAddressChecker|MockObject */ private $localAddressChecker; /** @var array */ @@ -40,13 +37,11 @@ class ClientTest extends \Test\TestCase { protected function setUp(): void { parent::setUp(); $this->config = $this->createMock(IConfig::class); - $this->logger = $this->createMock(ILogger::class); $this->guzzleClient = $this->createMock(\GuzzleHttp\Client::class); $this->certificateManager = $this->createMock(ICertificateManager::class); $this->localAddressChecker = $this->createMock(LocalAddressChecker::class); $this->client = new Client( $this->config, - $this->logger, $this->certificateManager, $this->guzzleClient, $this->localAddressChecker @@ -244,7 +239,7 @@ class ClientTest extends \Test\TestCase { ->method('ThrowIfLocalAddress') ->with('http://' . $uri) ->will($this->throwException(new LocalServerException())); - + $this->client->post('http://' . $uri); } @@ -259,7 +254,7 @@ class ClientTest extends \Test\TestCase { ->method('ThrowIfLocalAddress') ->with('http://' . $uri) ->will($this->throwException(new LocalServerException())); - + $this->client->put('http://' . $uri); } @@ -292,7 +287,7 @@ class ClientTest extends \Test\TestCase { ->method('getSystemValueBool') ->with('allow_local_remote_servers', false) ->willReturn(true); - + $this->certificateManager ->expects($this->once()) ->method('getAbsoluteBundlePath') diff --git a/tests/lib/Http/Client/LocalAddressCheckerTest.php b/tests/lib/Http/Client/LocalAddressCheckerTest.php index b2e09c0700b..0bba1cee5f4 100644 --- a/tests/lib/Http/Client/LocalAddressCheckerTest.php +++ b/tests/lib/Http/Client/LocalAddressCheckerTest.php @@ -26,9 +26,9 @@ declare(strict_types=1); namespace Test\Http\Client; -use OCP\ILogger; use OCP\Http\Client\LocalServerException; use OC\Http\Client\LocalAddressChecker; +use Psr\Log\LoggerInterface; class LocalAddressCheckerTest extends \Test\TestCase { /** @var LocalAddressChecker */ @@ -37,7 +37,7 @@ class LocalAddressCheckerTest extends \Test\TestCase { protected function setUp(): void { parent::setUp(); - $logger = $this->createMock(ILogger::class); + $logger = $this->createMock(LoggerInterface::class); $this->localAddressChecker = new LocalAddressChecker($logger); } diff --git a/tests/lib/Lock/DBLockingProviderTest.php b/tests/lib/Lock/DBLockingProviderTest.php index 31abd330fed..d45c379ff08 100644 --- a/tests/lib/Lock/DBLockingProviderTest.php +++ b/tests/lib/Lock/DBLockingProviderTest.php @@ -23,6 +23,7 @@ namespace Test\Lock; use OCP\AppFramework\Utility\ITimeFactory; use OCP\Lock\ILockingProvider; +use Psr\Log\LoggerInterface; /** * Class DBLockingProvider @@ -65,7 +66,7 @@ class DBLockingProviderTest extends LockingProvider { */ protected function getInstance() { $this->connection = \OC::$server->getDatabaseConnection(); - return new \OC\Lock\DBLockingProvider($this->connection, \OC::$server->getLogger(), $this->timeFactory, 3600); + return new \OC\Lock\DBLockingProvider($this->connection, \OC::$server->get(LoggerInterface::class), $this->timeFactory, 3600); } protected function tearDown(): void { diff --git a/tests/lib/Lock/NonCachingDBLockingProviderTest.php b/tests/lib/Lock/NonCachingDBLockingProviderTest.php index a5da1f8de75..973337edb4e 100644 --- a/tests/lib/Lock/NonCachingDBLockingProviderTest.php +++ b/tests/lib/Lock/NonCachingDBLockingProviderTest.php @@ -22,6 +22,7 @@ namespace Test\Lock; use OCP\Lock\ILockingProvider; +use Psr\Log\LoggerInterface; /** * @group DB @@ -34,7 +35,7 @@ class NonCachingDBLockingProviderTest extends DBLockingProviderTest { */ protected function getInstance() { $this->connection = \OC::$server->getDatabaseConnection(); - return new \OC\Lock\DBLockingProvider($this->connection, \OC::$server->getLogger(), $this->timeFactory, 3600, false); + return new \OC\Lock\DBLockingProvider($this->connection, \OC::$server->get(LoggerInterface::class), $this->timeFactory, 3600, false); } public function testDoubleShared() { diff --git a/tests/lib/Mail/MailerTest.php b/tests/lib/Mail/MailerTest.php index 335f373f8c1..e96cda26398 100644 --- a/tests/lib/Mail/MailerTest.php +++ b/tests/lib/Mail/MailerTest.php @@ -18,10 +18,10 @@ use OCP\Defaults; use OCP\EventDispatcher\IEventDispatcher; use OCP\IConfig; use OCP\IL10N; -use OCP\ILogger; use OCP\IURLGenerator; use OCP\L10N\IFactory; use OCP\Mail\Events\BeforeMessageSent; +use Psr\Log\LoggerInterface; use Swift_SwiftException; use Test\TestCase; @@ -30,7 +30,7 @@ class MailerTest extends TestCase { private $config; /** @var Defaults|\PHPUnit\Framework\MockObject\MockObject */ private $defaults; - /** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */ + /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */ private $logger; /** @var IURLGenerator|\PHPUnit\Framework\MockObject\MockObject */ private $urlGenerator; @@ -47,7 +47,7 @@ class MailerTest extends TestCase { $this->config = $this->createMock(IConfig::class); $this->defaults = $this->createMock(Defaults::class); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->urlGenerator = $this->createMock(IURLGenerator::class); $this->l10n = $this->createMock(IL10N::class); $this->dispatcher = $this->createMock(IEventDispatcher::class); diff --git a/tests/lib/Memcache/FactoryTest.php b/tests/lib/Memcache/FactoryTest.php index 858bdc5d3ef..0e995865b5d 100644 --- a/tests/lib/Memcache/FactoryTest.php +++ b/tests/lib/Memcache/FactoryTest.php @@ -22,7 +22,7 @@ namespace Test\Memcache; use OC\Memcache\NullCache; -use OCP\ILogger; +use Psr\Log\LoggerInterface; class Test_Factory_Available_Cache1 extends NullCache { public function __construct($prefix = '') { @@ -118,7 +118,7 @@ class FactoryTest extends \Test\TestCase { */ public function testCacheAvailability($localCache, $distributedCache, $lockingCache, $expectedLocalCache, $expectedDistributedCache, $expectedLockingCache) { - $logger = $this->getMockBuilder(ILogger::class)->getMock(); + $logger = $this->getMockBuilder(LoggerInterface::class)->getMock(); $factory = new \OC\Memcache\Factory('abc', $logger, $localCache, $distributedCache, $lockingCache); $this->assertTrue(is_a($factory->createLocal(), $expectedLocalCache)); $this->assertTrue(is_a($factory->createDistributed(), $expectedDistributedCache)); @@ -131,7 +131,7 @@ class FactoryTest extends \Test\TestCase { public function testCacheNotAvailableException($localCache, $distributedCache) { $this->expectException(\OCP\HintException::class); - $logger = $this->getMockBuilder(ILogger::class)->getMock(); + $logger = $this->getMockBuilder(LoggerInterface::class)->getMock(); new \OC\Memcache\Factory('abc', $logger, $localCache, $distributedCache); } } diff --git a/tests/lib/Repair/RepairCollationTest.php b/tests/lib/Repair/RepairCollationTest.php index 35679eb8630..27d146fab43 100644 --- a/tests/lib/Repair/RepairCollationTest.php +++ b/tests/lib/Repair/RepairCollationTest.php @@ -11,8 +11,8 @@ namespace Test\Repair; use Doctrine\DBAL\Platforms\MySqlPlatform; use OC\Repair\Collation; use OCP\IDBConnection; -use OCP\ILogger; use OCP\Migration\IOutput; +use Psr\Log\LoggerInterface; use Test\TestCase; class TestCollationRepair extends Collation { @@ -54,14 +54,14 @@ class RepairCollationTest extends TestCase { */ private $config; - /** @var ILogger */ + /** @var LoggerInterface */ private $logger; protected function setUp(): void { parent::setUp(); $this->connection = \OC::$server->get(IDBConnection::class); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->config = \OC::$server->getConfig(); if (!$this->connection->getDatabasePlatform() instanceof MySqlPlatform) { $this->markTestSkipped("Test only relevant on MySql"); diff --git a/tests/lib/Route/RouterTest.php b/tests/lib/Route/RouterTest.php index 4fcd9d65cd1..1f03f4edecb 100644 --- a/tests/lib/Route/RouterTest.php +++ b/tests/lib/Route/RouterTest.php @@ -24,7 +24,7 @@ declare(strict_types=1); namespace Test\Route; use OC\Route\Router; -use OCP\ILogger; +use Psr\Log\LoggerInterface; use Test\TestCase; /** @@ -34,8 +34,8 @@ use Test\TestCase; */ class RouterTest extends TestCase { public function testGenerateConsecutively(): void { - /** @var ILogger $logger */ - $logger = $this->createMock(ILogger::class); + /** @var LoggerInterface $logger */ + $logger = $this->createMock(LoggerInterface::class); $router = new Router($logger); $this->assertEquals('/index.php/apps/files/', $router->generate('files.view.index')); diff --git a/tests/lib/Security/Bruteforce/ThrottlerTest.php b/tests/lib/Security/Bruteforce/ThrottlerTest.php index fb28a7c9c7a..6639f884ae1 100644 --- a/tests/lib/Security/Bruteforce/ThrottlerTest.php +++ b/tests/lib/Security/Bruteforce/ThrottlerTest.php @@ -28,7 +28,7 @@ use OC\AppFramework\Utility\TimeFactory; use OC\Security\Bruteforce\Throttler; use OCP\IConfig; use OCP\IDBConnection; -use OCP\ILogger; +use Psr\Log\LoggerInterface; use Test\TestCase; /** @@ -42,14 +42,14 @@ class ThrottlerTest extends TestCase { private $throttler; /** @var IDBConnection */ private $dbConnection; - /** @var ILogger */ + /** @var LoggerInterface */ private $logger; /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */ private $config; protected function setUp(): void { $this->dbConnection = $this->createMock(IDBConnection::class); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->config = $this->createMock(IConfig::class); $this->throttler = new Throttler( diff --git a/tests/lib/Security/CertificateManagerTest.php b/tests/lib/Security/CertificateManagerTest.php index c50296c2a33..b1659d1096d 100644 --- a/tests/lib/Security/CertificateManagerTest.php +++ b/tests/lib/Security/CertificateManagerTest.php @@ -14,8 +14,8 @@ namespace Test\Security; use OC\Files\View; use OC\Security\CertificateManager; use OCP\IConfig; -use OCP\ILogger; use OCP\Security\ISecureRandom; +use Psr\Log\LoggerInterface; /** * Class CertificateManagerTest @@ -58,7 +58,7 @@ class CertificateManagerTest extends \Test\TestCase { $this->certificateManager = new CertificateManager( new \OC\Files\View(), $config, - $this->createMock(ILogger::class), + $this->createMock(LoggerInterface::class), $this->random ); } @@ -156,7 +156,7 @@ class CertificateManagerTest extends \Test\TestCase { /** @var CertificateManager | \PHPUnit\Framework\MockObject\MockObject $certificateManager */ $certificateManager = $this->getMockBuilder('OC\Security\CertificateManager') - ->setConstructorArgs([$view, $config, $this->createMock(ILogger::class), $this->random]) + ->setConstructorArgs([$view, $config, $this->createMock(LoggerInterface::class), $this->random]) ->setMethods(['getFilemtimeOfCaBundle', 'getCertificateBundle']) ->getMock(); diff --git a/tests/lib/Security/IdentityProof/ManagerTest.php b/tests/lib/Security/IdentityProof/ManagerTest.php index 0a6f97f3fcd..968cfa633ca 100644 --- a/tests/lib/Security/IdentityProof/ManagerTest.php +++ b/tests/lib/Security/IdentityProof/ManagerTest.php @@ -32,10 +32,10 @@ use OCP\Files\IAppData; use OCP\Files\SimpleFS\ISimpleFile; use OCP\Files\SimpleFS\ISimpleFolder; use OCP\IConfig; -use OCP\ILogger; use OCP\IUser; use OCP\Security\ICrypto; use PHPUnit\Framework\MockObject\MockObject; +use Psr\Log\LoggerInterface; use Test\TestCase; class ManagerTest extends TestCase { @@ -49,7 +49,7 @@ class ManagerTest extends TestCase { private $manager; /** @var IConfig|MockObject */ private $config; - /** @var ILogger|MockObject */ + /** @var LoggerInterface|MockObject */ private $logger; protected function setUp(): void { @@ -63,7 +63,7 @@ class ManagerTest extends TestCase { ->method('get') ->with('identityproof') ->willReturn($this->appData); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->crypto = $this->createMock(ICrypto::class); $this->manager = $this->getManager(['generateKeyPair']); diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php index 93f33fe30b9..9b8bc629594 100644 --- a/tests/lib/Share20/ManagerTest.php +++ b/tests/lib/Share20/ManagerTest.php @@ -41,7 +41,6 @@ use OCP\IConfig; use OCP\IGroup; use OCP\IGroupManager; use OCP\IL10N; -use OCP\ILogger; use OCP\IServerContainer; use OCP\IURLGenerator; use OCP\IUser; @@ -60,6 +59,7 @@ use OCP\Share\IShare; use OCP\Share\IShareProvider; use PHPUnit\Framework\MockObject\MockBuilder; use PHPUnit\Framework\MockObject\MockObject; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\GenericEvent; @@ -73,7 +73,7 @@ class ManagerTest extends \Test\TestCase { /** @var Manager */ protected $manager; - /** @var ILogger|MockObject */ + /** @var LoggerInterface|MockObject */ protected $logger; /** @var IConfig|MockObject */ protected $config; @@ -113,7 +113,7 @@ class ManagerTest extends \Test\TestCase { protected $knownUserService; protected function setUp(): void { - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->config = $this->createMock(IConfig::class); $this->secureRandom = $this->createMock(ISecureRandom::class); $this->hasher = $this->createMock(IHasher::class); diff --git a/tests/lib/TempManagerTest.php b/tests/lib/TempManagerTest.php index fd4ef8e2324..b85bbc8098b 100644 --- a/tests/lib/TempManagerTest.php +++ b/tests/lib/TempManagerTest.php @@ -34,8 +34,8 @@ class TempManagerTest extends \Test\TestCase { } /** - * @param \OCP\ILogger $logger - * @param \OCP\IConfig $config + * @param ?LoggerInterface $logger + * @param ?IConfig $config * @return \OC\TempManager */ protected function getManager($logger = null, $config = null) { diff --git a/tests/lib/Template/CSSResourceLocatorTest.php b/tests/lib/Template/CSSResourceLocatorTest.php index 3a66d738f25..4832b03fe9b 100644 --- a/tests/lib/Template/CSSResourceLocatorTest.php +++ b/tests/lib/Template/CSSResourceLocatorTest.php @@ -34,8 +34,8 @@ use OCP\AppFramework\Utility\ITimeFactory; use OCP\Files\IAppData; use OCP\ICacheFactory; use OCP\IConfig; -use OCP\ILogger; use OCP\IURLGenerator; +use Psr\Log\LoggerInterface; class CSSResourceLocatorTest extends \Test\TestCase { /** @var IAppData|\PHPUnit\Framework\MockObject\MockObject */ @@ -48,7 +48,7 @@ class CSSResourceLocatorTest extends \Test\TestCase { protected $themingDefaults; /** @var ICacheFactory|\PHPUnit\Framework\MockObject\MockObject */ protected $cacheFactory; - /** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */ + /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */ protected $logger; /** @var IconsCacher|\PHPUnit\Framework\MockObject\MockObject */ protected $iconsCacher; @@ -60,7 +60,7 @@ class CSSResourceLocatorTest extends \Test\TestCase { protected function setUp(): void { parent::setUp(); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->appData = $this->createMock(AppData::class); $this->urlGenerator = $this->createMock(IURLGenerator::class); $this->config = $this->createMock(IConfig::class); diff --git a/tests/lib/Template/IconsCacherTest.php b/tests/lib/Template/IconsCacherTest.php index 24b3c21052f..188c0596799 100644 --- a/tests/lib/Template/IconsCacherTest.php +++ b/tests/lib/Template/IconsCacherTest.php @@ -32,11 +32,11 @@ use OCP\AppFramework\Utility\ITimeFactory; use OCP\Files\IAppData; use OCP\Files\SimpleFS\ISimpleFile; use OCP\Files\SimpleFS\ISimpleFolder; -use OCP\ILogger; use OCP\IURLGenerator; +use Psr\Log\LoggerInterface; class IconsCacherTest extends \Test\TestCase { - /** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */ + /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */ protected $logger; /** @var IAppData|\PHPUnit\Framework\MockObject\MockObject */ protected $appData; @@ -46,7 +46,7 @@ class IconsCacherTest extends \Test\TestCase { private $timeFactory; protected function setUp(): void { - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->appData = $this->createMock(AppData::class); $this->timeFactory = $this->createMock(ITimeFactory::class); @@ -110,8 +110,7 @@ class IconsCacherTest extends \Test\TestCase { "; $expected = " icon.test { - - background-image: var(--icon-test); + \n background-image: var(--icon-test); } "; @@ -133,8 +132,7 @@ class IconsCacherTest extends \Test\TestCase { "; $expected = " icon.test { - - background-image: var(--icon-test); + \n background-image: var(--icon-test); } "; diff --git a/tests/lib/Template/JSCombinerTest.php b/tests/lib/Template/JSCombinerTest.php index 87abff99123..5c678840c63 100644 --- a/tests/lib/Template/JSCombinerTest.php +++ b/tests/lib/Template/JSCombinerTest.php @@ -32,8 +32,8 @@ use OCP\Files\SimpleFS\ISimpleFile; use OCP\Files\SimpleFS\ISimpleFolder; use OCP\ICache; use OCP\ICacheFactory; -use OCP\ILogger; use OCP\IURLGenerator; +use Psr\Log\LoggerInterface; class JSCombinerTest extends \Test\TestCase { /** @var IAppData|\PHPUnit\Framework\MockObject\MockObject */ @@ -46,7 +46,7 @@ class JSCombinerTest extends \Test\TestCase { protected $depsCache; /** @var JSCombiner */ protected $jsCombiner; - /** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */ + /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */ protected $logger; /** @var ICacheFactory|\PHPUnit\Framework\MockObject\MockObject */ protected $cacheFactory; @@ -62,7 +62,7 @@ class JSCombinerTest extends \Test\TestCase { $this->cacheFactory->expects($this->at(0)) ->method('createDistributed') ->willReturn($this->depsCache); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->jsCombiner = new JSCombiner( $this->appData, $this->urlGenerator, diff --git a/tests/lib/Template/JSResourceLocatorTest.php b/tests/lib/Template/JSResourceLocatorTest.php index e3e1398dd17..7dedd4ad3c7 100644 --- a/tests/lib/Template/JSResourceLocatorTest.php +++ b/tests/lib/Template/JSResourceLocatorTest.php @@ -28,8 +28,8 @@ use OC\Template\JSCombiner; use OC\Template\JSResourceLocator; use OCP\Files\IAppData; use OCP\ICacheFactory; -use OCP\ILogger; use OCP\IURLGenerator; +use Psr\Log\LoggerInterface; class JSResourceLocatorTest extends \Test\TestCase { /** @var IAppData|\PHPUnit\Framework\MockObject\MockObject */ @@ -40,7 +40,7 @@ class JSResourceLocatorTest extends \Test\TestCase { protected $config; /** @var ICacheFactory|\PHPUnit\Framework\MockObject\MockObject */ protected $cacheFactory; - /** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */ + /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */ protected $logger; protected function setUp(): void { @@ -50,7 +50,7 @@ class JSResourceLocatorTest extends \Test\TestCase { $this->urlGenerator = $this->createMock(IURLGenerator::class); $this->config = $this->createMock(SystemConfig::class); $this->cacheFactory = $this->createMock(ICacheFactory::class); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); } private function jsResourceLocator() { diff --git a/tests/lib/Template/ResourceLocatorTest.php b/tests/lib/Template/ResourceLocatorTest.php index 04691451079..0cb28843a53 100644 --- a/tests/lib/Template/ResourceLocatorTest.php +++ b/tests/lib/Template/ResourceLocatorTest.php @@ -9,7 +9,7 @@ namespace Test\Template; use OC\Template\ResourceNotFoundException; -use OCP\ILogger; +use Psr\Log\LoggerInterface; class ResourceLocatorTest extends \Test\TestCase { /** @var \PHPUnit\Framework\MockObject\MockObject */ @@ -17,7 +17,7 @@ class ResourceLocatorTest extends \Test\TestCase { protected function setUp(): void { parent::setUp(); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); } /** diff --git a/tests/lib/Template/SCSSCacherTest.php b/tests/lib/Template/SCSSCacherTest.php index 15966521a53..f7b7b3bb6d3 100644 --- a/tests/lib/Template/SCSSCacherTest.php +++ b/tests/lib/Template/SCSSCacherTest.php @@ -37,11 +37,11 @@ use OCP\Files\SimpleFS\ISimpleFolder; use OCP\ICache; use OCP\ICacheFactory; use OCP\IConfig; -use OCP\ILogger; use OCP\IURLGenerator; +use Psr\Log\LoggerInterface; class SCSSCacherTest extends \Test\TestCase { - /** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */ + /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */ protected $logger; /** @var IAppData|\PHPUnit\Framework\MockObject\MockObject */ protected $appData; @@ -68,7 +68,7 @@ class SCSSCacherTest extends \Test\TestCase { protected function setUp(): void { parent::setUp(); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->appData = $this->createMock(AppData::class); $this->iconsCacher = $this->createMock(IconsCacher::class); $this->timeFactory = $this->createMock(ITimeFactory::class); diff --git a/tests/lib/Traits/EncryptionTrait.php b/tests/lib/Traits/EncryptionTrait.php index 9cb64c12d00..23f188ccd66 100644 --- a/tests/lib/Traits/EncryptionTrait.php +++ b/tests/lib/Traits/EncryptionTrait.php @@ -16,6 +16,7 @@ use OCA\Encryption\KeyManager; use OCA\Encryption\Users\Setup; use OCP\Encryption\IManager; use OCP\IUserManager; +use Psr\Log\LoggerInterface; /** * Enables encryption @@ -82,7 +83,7 @@ trait EncryptionTrait { $encryptionWrapper = new EncryptionWrapper( new ArrayCache(), \OC::$server->getEncryptionManager(), - \OC::$server->getLogger() + \OC::$server->get(LoggerInterface::class) ); $this->registerStorageWrapper('oc_encryption', [$encryptionWrapper, 'wrapStorage']); diff --git a/tests/lib/Updater/ChangesCheckTest.php b/tests/lib/Updater/ChangesCheckTest.php index 223cbb45f66..02da6d08401 100644 --- a/tests/lib/Updater/ChangesCheckTest.php +++ b/tests/lib/Updater/ChangesCheckTest.php @@ -33,8 +33,8 @@ use OCP\AppFramework\Db\DoesNotExistException; use OCP\Http\Client\IClient; use OCP\Http\Client\IClientService; use OCP\Http\Client\IResponse; -use OCP\ILogger; use Test\TestCase; +use Psr\Log\LoggerInterface; class ChangesCheckTest extends TestCase { /** @var IClientService|\PHPUnit\Framework\MockObject\MockObject */ @@ -46,7 +46,7 @@ class ChangesCheckTest extends TestCase { /** @var ChangesMapper|\PHPUnit\Framework\MockObject\MockObject */ protected $mapper; - /** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */ + /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */ protected $logger; protected function setUp(): void { @@ -54,7 +54,7 @@ class ChangesCheckTest extends TestCase { $this->clientService = $this->createMock(IClientService::class); $this->mapper = $this->createMock(ChangesMapper::class); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->checker = new ChangesCheck($this->clientService, $this->mapper, $this->logger); } diff --git a/tests/lib/User/SessionTest.php b/tests/lib/User/SessionTest.php index fcd45bab5bd..0e199e5d5b5 100644 --- a/tests/lib/User/SessionTest.php +++ b/tests/lib/User/SessionTest.php @@ -24,7 +24,6 @@ use OCP\AppFramework\Utility\ITimeFactory; use OCP\EventDispatcher\IEventDispatcher; use OCP\ICacheFactory; use OCP\IConfig; -use OCP\ILogger; use OCP\IRequest; use OCP\IRequestId; use OCP\ISession; @@ -33,6 +32,7 @@ use OCP\Lockdown\ILockdownManager; use OCP\Security\ISecureRandom; use OCP\User\Events\PostLoginEvent; use PHPUnit\Framework\MockObject\MockObject; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use OC\Security\CSRF\CsrfTokenManager; @@ -57,7 +57,7 @@ class SessionTest extends \Test\TestCase { private $userSession; /** @var ILockdownManager|MockObject */ private $lockdownManager; - /** @var ILogger|MockObject */ + /** @var LoggerInterface|MockObject */ private $logger; /** @var IEventDispatcher|MockObject */ private $dispatcher; @@ -76,7 +76,7 @@ class SessionTest extends \Test\TestCase { $this->manager = $this->createMock(Manager::class); $this->session = $this->createMock(ISession::class); $this->lockdownManager = $this->createMock(ILockdownManager::class); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->dispatcher = $this->createMock(IEventDispatcher::class); $this->userSession = $this->getMockBuilder(Session::class) ->setConstructorArgs([ |