diff --git a/CHANGELOG.md b/CHANGELOG.md index c0ff3d765b..e40d4a40f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ The format is mostly based on [Keep a Changelog](https://keepachangelog.com/en/1 - Add DB index for news_feeds.deleted_at (#2526) ### Fixed +- Mark over 65535 unread items as "read" # Releases ## [25.0.0-alpha3] - 2023-12-24 diff --git a/lib/Db/FeedMapperV2.php b/lib/Db/FeedMapperV2.php index c80bf118b3..7015dc53b0 100644 --- a/lib/Db/FeedMapperV2.php +++ b/lib/Db/FeedMapperV2.php @@ -186,21 +186,27 @@ function ($value): int { }, $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); + $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; } }