diff options
author | Marcel Klehr <mklehr@gmx.net> | 2024-05-07 12:46:21 +0200 |
---|---|---|
committer | Marcel Klehr <mklehr@gmx.net> | 2024-05-14 11:38:41 +0200 |
commit | 4a3b9b826ea532991f8636b621f92760c321e93e (patch) | |
tree | 46c57ff0648993a2025ca7d25d0c491fc66f92b5 /lib/private | |
parent | fff2fb8e77c7a58aa9323c13daa355d6d8f3a118 (diff) | |
download | nextcloud-server-4a3b9b826ea532991f8636b621f92760c321e93e.tar.gz nextcloud-server-4a3b9b826ea532991f8636b621f92760c321e93e.zip |
refactor: identifier is now customId/custom_id
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Log/PsrLoggerAdapter.php | 37 | ||||
-rw-r--r-- | lib/private/TaskProcessing/Db/Task.php | 12 | ||||
-rw-r--r-- | lib/private/TaskProcessing/Db/TaskMapper.php | 8 | ||||
-rw-r--r-- | lib/private/TaskProcessing/Manager.php | 4 | ||||
-rw-r--r-- | lib/private/TaskProcessing/SynchronousBackgroundJob.php | 2 |
5 files changed, 31 insertions, 32 deletions
diff --git a/lib/private/Log/PsrLoggerAdapter.php b/lib/private/Log/PsrLoggerAdapter.php index 8b397ef8905..b126cb52d77 100644 --- a/lib/private/Log/PsrLoggerAdapter.php +++ b/lib/private/Log/PsrLoggerAdapter.php @@ -31,7 +31,6 @@ use OCP\ILogger; use OCP\Log\IDataLogger; use Psr\Log\InvalidArgumentException; use Psr\Log\LoggerInterface; -use Stringable; use Throwable; use function array_key_exists; use function array_merge; @@ -53,10 +52,10 @@ final class PsrLoggerAdapter implements LoggerInterface, IDataLogger { /** * System is unusable. * - * @param string|Stringable $message + * @param $message * @param mixed[] $context */ - public function emergency(string|Stringable $message, array $context = []): void { + public function emergency($message, array $context = []): void { if ($this->containsThrowable($context)) { $this->logger->logException($context['exception'], array_merge( [ @@ -76,10 +75,10 @@ final class PsrLoggerAdapter implements LoggerInterface, IDataLogger { * Example: Entire website down, database unavailable, etc. This should * trigger the SMS alerts and wake you up. * - * @param string|Stringable $message + * @param $message * @param mixed[] $context */ - public function alert(string|Stringable $message, array $context = []): void { + public function alert($message, array $context = []): void { if ($this->containsThrowable($context)) { $this->logger->logException($context['exception'], array_merge( [ @@ -98,10 +97,10 @@ final class PsrLoggerAdapter implements LoggerInterface, IDataLogger { * * Example: Application component unavailable, unexpected exception. * - * @param string|Stringable $message + * @param $message * @param mixed[] $context */ - public function critical(string|Stringable $message, array $context = []): void { + public function critical($message, array $context = []): void { if ($this->containsThrowable($context)) { $this->logger->logException($context['exception'], array_merge( [ @@ -119,10 +118,10 @@ final class PsrLoggerAdapter implements LoggerInterface, IDataLogger { * Runtime errors that do not require immediate action but should typically * be logged and monitored. * - * @param string|Stringable $message + * @param $message * @param mixed[] $context */ - public function error(string|Stringable $message, array $context = []): void { + public function error($message, array $context = []): void { if ($this->containsThrowable($context)) { $this->logger->logException($context['exception'], array_merge( [ @@ -142,10 +141,10 @@ final class PsrLoggerAdapter implements LoggerInterface, IDataLogger { * Example: Use of deprecated APIs, poor use of an API, undesirable things * that are not necessarily wrong. * - * @param string|Stringable $message + * @param $message * @param mixed[] $context */ - public function warning(string|Stringable $message, array $context = []): void { + public function warning($message, array $context = []): void { if ($this->containsThrowable($context)) { $this->logger->logException($context['exception'], array_merge( [ @@ -162,10 +161,10 @@ final class PsrLoggerAdapter implements LoggerInterface, IDataLogger { /** * Normal but significant events. * - * @param string|Stringable $message + * @param $message * @param mixed[] $context */ - public function notice(string|Stringable $message, array $context = []): void { + public function notice($message, array $context = []): void { if ($this->containsThrowable($context)) { $this->logger->logException($context['exception'], array_merge( [ @@ -184,10 +183,10 @@ final class PsrLoggerAdapter implements LoggerInterface, IDataLogger { * * Example: User logs in, SQL logs. * - * @param string|Stringable $message + * @param $message * @param mixed[] $context */ - public function info(string|Stringable $message, array $context = []): void { + public function info($message, array $context = []): void { if ($this->containsThrowable($context)) { $this->logger->logException($context['exception'], array_merge( [ @@ -204,10 +203,10 @@ final class PsrLoggerAdapter implements LoggerInterface, IDataLogger { /** * Detailed debug information. * - * @param string|Stringable $message + * @param $message * @param mixed[] $context */ - public function debug(string|Stringable $message, array $context = []): void { + public function debug($message, array $context = []): void { if ($this->containsThrowable($context)) { $this->logger->logException($context['exception'], array_merge( [ @@ -225,12 +224,12 @@ final class PsrLoggerAdapter implements LoggerInterface, IDataLogger { * Logs with an arbitrary level. * * @param mixed $level - * @param string|Stringable $message + * @param $message * @param mixed[] $context * * @throws InvalidArgumentException */ - public function log($level, string|Stringable $message, array $context = []): void { + public function log($level, $message, array $context = []): void { if (!is_int($level) || $level < ILogger::DEBUG || $level > ILogger::FATAL) { throw new InvalidArgumentException('Nextcloud allows only integer log levels'); } diff --git a/lib/private/TaskProcessing/Db/Task.php b/lib/private/TaskProcessing/Db/Task.php index 6e181285c90..11892a14960 100644 --- a/lib/private/TaskProcessing/Db/Task.php +++ b/lib/private/TaskProcessing/Db/Task.php @@ -43,7 +43,7 @@ use OCP\TaskProcessing\Task as OCPTask; * @method string|null getUserId() * @method setAppId(string $type) * @method string getAppId() - * @method setIdentifier(string $identifier) + * @method setIdentifier(string $customId) * @method string getIdentifier() * @method setCompletionExpectedAt(null|\DateTime $completionExpectedAt) * @method null|\DateTime getCompletionExpectedAt() @@ -60,7 +60,7 @@ class Task extends Entity { protected $status; protected $userId; protected $appId; - protected $identifier; + protected $customId; protected $completionExpectedAt; protected $errorMessage; protected $progress; @@ -68,12 +68,12 @@ class Task extends Entity { /** * @var string[] */ - public static array $columns = ['id', 'last_updated', 'type', 'input', 'output', 'status', 'user_id', 'app_id', 'identifier', 'completion_expected_at', 'error_message', 'progress']; + public static array $columns = ['id', 'last_updated', 'type', 'input', 'output', 'status', 'user_id', 'app_id', 'custom_id', 'completion_expected_at', 'error_message', 'progress']; /** * @var string[] */ - public static array $fields = ['id', 'lastUpdated', 'type', 'input', 'output', 'status', 'userId', 'appId', 'identifier', 'completionExpectedAt', 'errorMessage', 'progress']; + public static array $fields = ['id', 'lastUpdated', 'type', 'input', 'output', 'status', 'userId', 'appId', 'customId', 'completionExpectedAt', 'errorMessage', 'progress']; public function __construct() { @@ -86,7 +86,7 @@ class Task extends Entity { $this->addType('status', 'integer'); $this->addType('userId', 'string'); $this->addType('appId', 'string'); - $this->addType('identifier', 'string'); + $this->addType('customId', 'string'); $this->addType('completionExpectedAt', 'datetime'); $this->addType('errorMessage', 'string'); $this->addType('progress', 'float'); @@ -110,7 +110,7 @@ class Task extends Entity { 'errorMessage' => $task->getErrorMessage(), 'userId' => $task->getUserId(), 'appId' => $task->getAppId(), - 'identifier' => $task->getIdentifier(), + 'customId' => $task->getIdentifier(), 'completionExpectedAt' => $task->getCompletionExpectedAt(), 'progress' => $task->getProgress(), ]); diff --git a/lib/private/TaskProcessing/Db/TaskMapper.php b/lib/private/TaskProcessing/Db/TaskMapper.php index 7ba16105f4c..bdb59e5180e 100644 --- a/lib/private/TaskProcessing/Db/TaskMapper.php +++ b/lib/private/TaskProcessing/Db/TaskMapper.php @@ -103,18 +103,18 @@ class TaskMapper extends QBMapper { /** * @param string $userId * @param string $appId - * @param string|null $identifier + * @param string|null $customId * @return list<Task> * @throws Exception */ - public function findUserTasksByApp(string $userId, string $appId, ?string $identifier = null): array { + public function findUserTasksByApp(string $userId, string $appId, ?string $customId = null): array { $qb = $this->db->getQueryBuilder(); $qb->select(Task::$columns) ->from($this->tableName) ->where($qb->expr()->eq('user_id', $qb->createPositionalParameter($userId))) ->andWhere($qb->expr()->eq('app_id', $qb->createPositionalParameter($appId))); - if ($identifier !== null) { - $qb->andWhere($qb->expr()->eq('identifier', $qb->createPositionalParameter($identifier))); + if ($customId !== null) { + $qb->andWhere($qb->expr()->eq('custom_id', $qb->createPositionalParameter($customId))); } return array_values($this->findEntities($qb)); } diff --git a/lib/private/TaskProcessing/Manager.php b/lib/private/TaskProcessing/Manager.php index 2770fd277ab..86587a94c23 100644 --- a/lib/private/TaskProcessing/Manager.php +++ b/lib/private/TaskProcessing/Manager.php @@ -797,9 +797,9 @@ class Manager implements IManager { } } - public function getUserTasksByApp(?string $userId, string $appId, ?string $identifier = null): array { + public function getUserTasksByApp(?string $userId, string $appId, ?string $customId = null): array { try { - $taskEntities = $this->taskMapper->findUserTasksByApp($userId, $appId, $identifier); + $taskEntities = $this->taskMapper->findUserTasksByApp($userId, $appId, $customId); return array_map(fn ($taskEntity): Task => $taskEntity->toPublicTask(), $taskEntities); } catch (\OCP\DB\Exception $e) { throw new \OCP\TaskProcessing\Exception\Exception('There was a problem finding a task', 0, $e); diff --git a/lib/private/TaskProcessing/SynchronousBackgroundJob.php b/lib/private/TaskProcessing/SynchronousBackgroundJob.php index c7f4706c392..ba1844b1da1 100644 --- a/lib/private/TaskProcessing/SynchronousBackgroundJob.php +++ b/lib/private/TaskProcessing/SynchronousBackgroundJob.php @@ -57,7 +57,7 @@ class SynchronousBackgroundJob extends QueuedJob { return; } try { - $output = $provider->process($task->getUserId(), $input); + $output = $provider->process($task->getUserId(), $input, fn(float $progress) => $this->taskProcessingManager->setTaskProgress($task->getId(), $progress)); } catch (ProcessingException $e) { $this->logger->warning('Failed to process a TaskProcessing task with synchronous provider ' . $provider->getId(), ['exception' => $e]); $this->taskProcessingManager->setTaskResult($task->getId(), $e->getMessage(), null); |