aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2024-09-04 09:35:16 +0200
committerGitHub <noreply@github.com>2024-09-04 09:35:16 +0200
commit8f825cbd1662429c6dd2c156bdd78ba1533c80cc (patch)
treeaa4b3ab251c9e6edbfa1555dd7db2f4b75193724 /lib/private
parentc28340dd5b8adc5f686e3c42706a5214ea0035ea (diff)
parent2156a927a3046d248d9e2f7e3621ded845e94f45 (diff)
downloadnextcloud-server-8f825cbd1662429c6dd2c156bdd78ba1533c80cc.tar.gz
nextcloud-server-8f825cbd1662429c6dd2c156bdd78ba1533c80cc.zip
Merge pull request #47155 from nextcloud/executeStatementOnDelete
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/BackgroundJob/JobList.php53
1 files changed, 16 insertions, 37 deletions
diff --git a/lib/private/BackgroundJob/JobList.php b/lib/private/BackgroundJob/JobList.php
index 77fa418cab8..5059199a182 100644
--- a/lib/private/BackgroundJob/JobList.php
+++ b/lib/private/BackgroundJob/JobList.php
@@ -24,27 +24,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) {
@@ -81,11 +74,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')
@@ -104,11 +93,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();
}
}
@@ -126,11 +115,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();
@@ -149,11 +134,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);
}
/**
@@ -168,11 +151,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)));
}