Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/mail.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2021-04-07 15:57:42 +0300
committerChristoph Wurst <christoph@winzerhof-wurst.at>2021-04-08 15:00:36 +0300
commit6ad917e85d088e02f674a7e377a8b187c0411ff1 (patch)
treee2933c224a56bf2073bdf499f60fabc904241764
parentb550749764941c14987cbfbaed3e1495678660d6 (diff)
Chunk huge arrays to surpress Oracle IN() warning
Signed-off-by: Joas Schilling <coding@schilljs.com> Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
-rw-r--r--lib/Db/MessageMapper.php12
-rw-r--r--tests/psalm-baseline.xml1
2 files changed, 10 insertions, 3 deletions
diff --git a/lib/Db/MessageMapper.php b/lib/Db/MessageMapper.php
index b51217e5c..204719bf1 100644
--- a/lib/Db/MessageMapper.php
+++ b/lib/Db/MessageMapper.php
@@ -176,10 +176,18 @@ class MessageMapper extends QBMapper {
->from($this->getTableName())
->where(
$query->expr()->eq('mailbox_id', $query->createNamedParameter($mailbox->getId(), IQueryBuilder::PARAM_INT), IQueryBuilder::PARAM_INT),
- $query->expr()->in('id', $query->createNamedParameter($ids, IQueryBuilder::PARAM_INT_ARRAY), IQueryBuilder::PARAM_INT_ARRAY)
+ $query->expr()->in('id', $query->createParameter('ids'), IQueryBuilder::PARAM_INT_ARRAY)
);
- return $this->findUids($query);
+ $chunks = array_chunk($ids, 1000);
+
+ $results = [];
+ foreach ($chunks as $chunk) {
+ $query->setParameter('ids', $chunk, IQueryBuilder::PARAM_INT_ARRAY);
+ $results[] = $this->findUids($query);
+ }
+
+ return array_merge(...$results);
}
/**
diff --git a/tests/psalm-baseline.xml b/tests/psalm-baseline.xml
index f05676999..7fc2965a8 100644
--- a/tests/psalm-baseline.xml
+++ b/tests/psalm-baseline.xml
@@ -124,7 +124,6 @@
<code>$qb2-&gt;createNamedParameter($ids, IQueryBuilder::PARAM_INT_ARRAY)</code>
<code>$qb2-&gt;createNamedParameter(array_keys($indexedMessages), IQueryBuilder::PARAM_INT_ARRAY)</code>
<code>$qb4-&gt;createNamedParameter($ids, IQueryBuilder::PARAM_INT_ARRAY)</code>
- <code>$query-&gt;createNamedParameter($ids, IQueryBuilder::PARAM_INT_ARRAY)</code>
<code>$query-&gt;createNamedParameter($uids, IQueryBuilder::PARAM_INT_ARRAY)</code>
</ImplicitToStringCast>
</file>