diff options
author | fenn-cs <fenn25.fn@gmail.com> | 2023-07-07 02:52:39 +0100 |
---|---|---|
committer | fenn-cs <fenn25.fn@gmail.com> | 2023-08-13 11:37:34 +0100 |
commit | dc8d25c2742220b3c199c31e0e703470799090f1 (patch) | |
tree | 4c06590e6827ec40e54d1366739601a1c70e0807 /apps/files/lib/BackgroundJob | |
parent | 4a2fbf72802e8b92422bccbfde8dc270f89be420 (diff) | |
download | nextcloud-server-dc8d25c2742220b3c199c31e0e703470799090f1.tar.gz nextcloud-server-dc8d25c2742220b3c199c31e0e703470799090f1.zip |
Migrate parts of files app away from depecrated Ilogger
- Migrate some backgrounds jobs, `TransferOwnership` & `DeleteOrphanedItems`
- Migrate `DirectEditingController`
Signed-off-by: fenn-cs <fenn25.fn@gmail.com>
Diffstat (limited to 'apps/files/lib/BackgroundJob')
-rw-r--r-- | apps/files/lib/BackgroundJob/DeleteOrphanedItems.php | 22 | ||||
-rw-r--r-- | apps/files/lib/BackgroundJob/TransferOwnership.php | 51 |
2 files changed, 23 insertions, 50 deletions
diff --git a/apps/files/lib/BackgroundJob/DeleteOrphanedItems.php b/apps/files/lib/BackgroundJob/DeleteOrphanedItems.php index 669c2a4cde6..6163955ddfd 100644 --- a/apps/files/lib/BackgroundJob/DeleteOrphanedItems.php +++ b/apps/files/lib/BackgroundJob/DeleteOrphanedItems.php @@ -27,34 +27,26 @@ namespace OCA\Files\BackgroundJob; use OCP\AppFramework\Utility\ITimeFactory; use OCP\BackgroundJob\TimedJob; use OCP\DB\QueryBuilder\IQueryBuilder; +use OCP\IDBConnection; +use Psr\Log\LoggerInterface; /** * Delete all share entries that have no matching entries in the file cache table. */ class DeleteOrphanedItems extends TimedJob { public const CHUNK_SIZE = 200; - - /** @var \OCP\IDBConnection */ - protected $connection; - - /** @var \OCP\ILogger */ - protected $logger; - - /** - * Default interval in minutes - * - * @var int $defaultIntervalMin - **/ protected $defaultIntervalMin = 60; /** * sets the correct interval for this timed job */ - public function __construct(ITimeFactory $time) { + public function __construct( + ITimeFactory $time, + protected IDBConnection $connection, + protected LoggerInterface $logger, + ) { parent::__construct($time); $this->interval = $this->defaultIntervalMin * 60; - $this->connection = \OC::$server->getDatabaseConnection(); - $this->logger = \OC::$server->getLogger(); } /** diff --git a/apps/files/lib/BackgroundJob/TransferOwnership.php b/apps/files/lib/BackgroundJob/TransferOwnership.php index 8c96fcf8385..9103c307b76 100644 --- a/apps/files/lib/BackgroundJob/TransferOwnership.php +++ b/apps/files/lib/BackgroundJob/TransferOwnership.php @@ -33,46 +33,23 @@ use OCA\Files\Service\OwnershipTransferService; use OCP\AppFramework\Utility\ITimeFactory; use OCP\BackgroundJob\QueuedJob; use OCP\Files\IRootFolder; -use OCP\ILogger; use OCP\IUser; use OCP\IUserManager; use OCP\Notification\IManager as NotificationManager; +use Psr\Log\LoggerInterface; use function ltrim; class TransferOwnership extends QueuedJob { - - /** @var IUserManager $userManager */ - private $userManager; - - /** @var OwnershipTransferService */ - private $transferService; - - /** @var ILogger */ - private $logger; - - /** @var NotificationManager */ - private $notificationManager; - - /** @var TransferOwnershipMapper */ - private $mapper; - /** @var IRootFolder */ - private $rootFolder; - - public function __construct(ITimeFactory $timeFactory, - IUserManager $userManager, - OwnershipTransferService $transferService, - ILogger $logger, - NotificationManager $notificationManager, - TransferOwnershipMapper $mapper, - IRootFolder $rootFolder) { + public function __construct( + ITimeFactory $timeFactory, + private IUserManager $userManager, + private OwnershipTransferService $transferService, + private LoggerInterface $logger, + private NotificationManager $notificationManager, + private TransferOwnershipMapper $mapper, + private IRootFolder $rootFolder, + ) { parent::__construct($timeFactory); - - $this->userManager = $userManager; - $this->transferService = $transferService; - $this->logger = $logger; - $this->notificationManager = $notificationManager; - $this->mapper = $mapper; - $this->rootFolder = $rootFolder; } protected function run($argument) { @@ -116,7 +93,12 @@ class TransferOwnership extends QueuedJob { ); $this->successNotification($transfer); } catch (TransferOwnershipException $e) { - $this->logger->logException($e); + $this->logger->error( + $e->getMessage(), + [ + 'exception' => $e, + ], + ); $this->failedNotication($transfer); } @@ -136,7 +118,6 @@ class TransferOwnership extends QueuedJob { ]) ->setObject('transfer', (string)$transfer->getId()); $this->notificationManager->notify($notification); - // Send notification to source user $notification = $this->notificationManager->createNotification(); $notification->setUser($transfer->getTargetUser()) |