diff options
author | Git'Fellow <12234510+solracsf@users.noreply.github.com> | 2024-08-09 22:38:33 +0200 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2024-09-04 07:37:09 +0000 |
commit | 6659ee4cf6eba2d779225f62b66aff34aae09acd (patch) | |
tree | 695200625bb6601c161a8f1ac95424cc355af00f /lib | |
parent | ffd220dfd2a34c0fb2fcb384e44e8415be8be311 (diff) | |
download | nextcloud-server-6659ee4cf6eba2d779225f62b66aff34aae09acd.tar.gz nextcloud-server-6659ee4cf6eba2d779225f62b66aff34aae09acd.zip |
fix(jobs): Swicth to executeStatement() while deleting rows
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/BackgroundJob/JobList.php | 53 |
1 files changed, 16 insertions, 37 deletions
diff --git a/lib/private/BackgroundJob/JobList.php b/lib/private/BackgroundJob/JobList.php index 851858245e9..92fe544ed3a 100644 --- a/lib/private/BackgroundJob/JobList.php +++ b/lib/private/BackgroundJob/JobList.php @@ -47,27 +47,20 @@ use function md5; use function strlen; class JobList implements IJobList { - protected IDBConnection $connection; - protected IConfig $config; - protected ITimeFactory $timeFactory; - protected LoggerInterface $logger; - - public function __construct(IDBConnection $connection, IConfig $config, ITimeFactory $timeFactory, LoggerInterface $logger) { - $this->connection = $connection; - $this->config = $config; - $this->timeFactory = $timeFactory; - $this->logger = $logger; + public function __construct( + protected IDBConnection $connection, + protected IConfig $config, + protected ITimeFactory $timeFactory, + protected LoggerInterface $logger + ) { } public function add($job, $argument = null, ?int $firstCheck = null): void { if ($firstCheck === null) { $firstCheck = $this->timeFactory->getTime(); } - if ($job instanceof IJob) { - $class = get_class($job); - } else { - $class = $job; - } + + $class = ($job instanceof IJob) ? get_class($job) : $job; $argumentJson = json_encode($argument); if (strlen($argumentJson) > 4000) { @@ -104,11 +97,7 @@ class JobList implements IJobList { * @param mixed $argument */ public function remove($job, $argument = null): void { - if ($job instanceof IJob) { - $class = get_class($job); - } else { - $class = $job; - } + $class = ($job instanceof IJob) ? get_class($job) : $job; $query = $this->connection->getQueryBuilder(); $query->delete('jobs') @@ -127,11 +116,11 @@ class JobList implements IJobList { $query->setMaxResults($max); do { - $deleted = $query->execute(); + $deleted = $query->executeStatement(); } while ($deleted === $max); } else { // Dont use chunked delete - let the DB handle the large row count natively - $query->execute(); + $query->executeStatement(); } } @@ -149,11 +138,7 @@ class JobList implements IJobList { * @param mixed $argument */ public function has($job, $argument): bool { - if ($job instanceof IJob) { - $class = get_class($job); - } else { - $class = $job; - } + $class = ($job instanceof IJob) ? get_class($job) : $job; $argument = json_encode($argument); $query = $this->connection->getQueryBuilder(); @@ -172,11 +157,9 @@ class JobList implements IJobList { public function getJobs($job, ?int $limit, int $offset): array { $iterable = $this->getJobsIterator($job, $limit, $offset); - if (is_array($iterable)) { - return $iterable; - } else { - return iterator_to_array($iterable); - } + return (is_array($iterable)) + ? $iterable + : iterator_to_array($iterable); } /** @@ -191,11 +174,7 @@ class JobList implements IJobList { ->setFirstResult($offset); if ($job !== null) { - if ($job instanceof IJob) { - $class = get_class($job); - } else { - $class = $job; - } + $class = ($job instanceof IJob) ? get_class($job) : $job; $query->where($query->expr()->eq('class', $query->createNamedParameter($class))); } |