@@ -59,17 +59,21 @@ public function onMultiStatus(&$fileProperties): void {
5959 $ offset = (int )$ request ->getHeader (self ::PAGINATE_OFFSET_HEADER );
6060
6161 $ copyIterator = new LimitedCopyIterator ($ fileProperties , $ pageSize , $ offset );
62- // wrap the iterator with another that renders XML, this way we
63- // cache XML, but we keep the first $pageSize elements as objects
64- // to use for the response of the first page.
65- $ rendererGenerator = $ this ->getXmlRendererGenerator ($ copyIterator );
66- ['token ' => $ token , 'count ' => $ count ] = $ this ->cache ->store ($ url , $ rendererGenerator );
62+
63+ if ($ copyIterator ->hasOthers ()) {
64+ // wrap the iterator with another that renders XML, this way we
65+ // cache XML, but we keep the first $pageSize elements as objects
66+ // to use for the response of the first page.
67+ $ rendererGenerator = $ this ->getXmlRendererGenerator ($ copyIterator );
68+ ['token ' => $ token , 'count ' => $ count ] = $ this ->cache ->store ($ url , $ rendererGenerator );
69+
70+ $ this ->server ->httpResponse ->addHeader (self ::PAGINATE_HEADER , 'true ' );
71+ $ this ->server ->httpResponse ->addHeader (self ::PAGINATE_TOKEN_HEADER , $ token );
72+ $ this ->server ->httpResponse ->addHeader (self ::PAGINATE_TOTAL_HEADER , (string )$ count );
73+ $ request ->setHeader (self ::PAGINATE_TOKEN_HEADER , $ token );
74+ }
6775
6876 $ fileProperties = $ copyIterator ->getRequestedItems ();
69- $ this ->server ->httpResponse ->addHeader (self ::PAGINATE_HEADER , 'true ' );
70- $ this ->server ->httpResponse ->addHeader (self ::PAGINATE_TOKEN_HEADER , $ token );
71- $ this ->server ->httpResponse ->addHeader (self ::PAGINATE_TOTAL_HEADER , (string )$ count );
72- $ request ->setHeader (self ::PAGINATE_TOKEN_HEADER , $ token );
7377 }
7478 }
7579
0 commit comments