From 793b0fa76db63629708f9f8d9ad12b65b3309469 Mon Sep 17 00:00:00 2001 From: lazerg Date: Sat, 31 Oct 2026 13:08:29 +0500 Subject: [PATCH] fix(dav): ignore paginated pages with evicted cache entries Assisted-by: Claude:claude-opus-5-5 Signed-off-by: lazerg --- apps/dav/lib/Paginate/PaginatePlugin.php | 5 +++- .../unit/Paginate/PaginatePluginTest.php | 23 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/apps/dav/lib/Paginate/PaginatePlugin.php b/apps/dav/lib/Paginate/PaginatePlugin.php index 234c7e25b75c6..846d39ee786f7 100644 --- a/apps/dav/lib/Paginate/PaginatePlugin.php +++ b/apps/dav/lib/Paginate/PaginatePlugin.php @@ -126,7 +126,10 @@ public function onMethod(RequestInterface $request, ResponseInterface $response) $offset = (int)$request->getHeader(self::PAGINATE_OFFSET_HEADER); $count = (int)$request->getHeader(self::PAGINATE_COUNT_HEADER) ?: $this->pageSize; - $items = $this->cache->get($url, $token, $offset, $count); + $items = iterator_to_array($this->cache->get($url, $token, $offset, $count), false); + if (in_array(null, $items, true)) { + return; + } $response->setStatus(207); $response->addHeader(self::PAGINATE_HEADER, 'true'); diff --git a/apps/dav/tests/unit/Paginate/PaginatePluginTest.php b/apps/dav/tests/unit/Paginate/PaginatePluginTest.php index 8d3d4cc9f781e..7eea7bbe35532 100644 --- a/apps/dav/tests/unit/Paginate/PaginatePluginTest.php +++ b/apps/dav/tests/unit/Paginate/PaginatePluginTest.php @@ -279,6 +279,29 @@ public function testOnMethodReturnsCachedResponse(): void { self::assertFalse($this->plugin->onMethod($this->request, $response)); } + public function testOnMethodIgnoresEvictedCacheEntries(): void { + $this->initializePlugin(); + + $this->request->method('hasHeader')->willReturn(true); + $this->request->method('getUrl')->willReturn('url'); + $this->request->method('getHeader')->willReturnMap([ + [PaginatePlugin::PAGINATE_TOKEN_HEADER, 'token'], + [PaginatePlugin::PAGINATE_OFFSET_HEADER, '0'], + [PaginatePlugin::PAGINATE_COUNT_HEADER, '2'], + ]); + + $this->cache->method('exists')->willReturn(true); + $this->cache->method('get')->willReturn((function (): \Generator { + yield $this->getResponseXmlForFile('/file1', 'File 1'); + yield null; + })()); + + $this->response->expects(self::never()) + ->method('setBody'); + + self::assertNull($this->plugin->onMethod($this->request, $this->response)); + } + public function testOnMultiStatusNoPaginateHeaderShouldSucceed(): void { $this->initializePlugin();