summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorIgorA100 <igora100@gmail.com>2024-01-20 18:15:45 +0300
committerBenjamin Brahmer <info@b-brahmer.de>2024-01-25 11:23:55 +0100
commit457aaa7aaf5d6a7432711f6fe1efddc8b7636de6 (patch)
tree4e65329ef2870b98db1b6e25841ff6b6aa421c56 /lib
parent719d4fd6b4f134181ae03169166da828ca031976 (diff)
Fix: Mark over 65535 unread items as "read"
If there are more than 65535 unread items, then when checking “mark as read” you will get an SQL error (SQLSTATE[HY000]: General error: 7 number of parameters must be between 0 and 65535 at) due to the limitation of the number of parameters. The array is divided into smaller ones. Signed-off-by: IgorA100 <igora100@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/Db/FeedMapperV2.php39
1 files changed, 23 insertions, 16 deletions
diff --git a/lib/Db/FeedMapperV2.php b/lib/Db/FeedMapperV2.php
index c80bf118b..55478198e 100644
--- a/lib/Db/FeedMapperV2.php
+++ b/lib/Db/FeedMapperV2.php
@@ -186,21 +186,28 @@ class FeedMapperV2 extends NewsMapperV2
},
$this->db->executeQuery($idBuilder->getSQL(), $idBuilder->getParameters())->fetchAll()
);
- $time = new Time();
- $builder = $this->db->getQueryBuilder();
- $builder->update(ItemMapperV2::TABLE_NAME)
- ->set('unread', $builder->createParameter('unread'))
- ->set('last_modified', $builder->createParameter('last_modified'))
- ->andWhere('id IN (:idList)')
- ->andWhere('unread != :unread')
- ->setParameter('unread', false, IQueryBuilder::PARAM_BOOL)
- ->setParameter('idList', $idList, IQueryBuilder::PARAM_INT_ARRAY)
- ->setParameter('last_modified', $time->getMicroTime(), IQueryBuilder::PARAM_STR);
-
- return $this->db->executeStatement(
- $builder->getSQL(),
- $builder->getParameters(),
- $builder->getParameterTypes()
- );
+
+ $chunked_idList = array_chunk($idList,65500,true);
+ $res = 0;
+ foreach ($chunked_idList as $idList_chunk)
+ {
+ $time = new Time();
+ $builder = $this->db->getQueryBuilder();
+ $builder->update(ItemMapperV2::TABLE_NAME)
+ ->set('unread', $builder->createParameter('unread'))
+ ->set('last_modified', $builder->createParameter('last_modified'))
+ ->andWhere('id IN (:idList)')
+ ->andWhere('unread != :unread')
+ ->setParameter('unread', false, IQueryBuilder::PARAM_BOOL)
+ ->setParameter('idList', $idList_chunk, IQueryBuilder::PARAM_INT_ARRAY)
+ ->setParameter('last_modified', $time->getMicroTime(), IQueryBuilder::PARAM_STR);
+
+ $res += $this->db->executeStatement(
+ $builder->getSQL(),
+ $builder->getParameters(),
+ $builder->getParameterTypes()
+ );
+ }
+ return $res;
}
}