Skip to content

Commit 9cecfab

Browse files
fix: only display hydra:next when the item total is strictly greater than the number of items per page (#3967)
1 parent 4f05477 commit 9cecfab

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

src/Hydra/Serializer/PartialCollectionViewNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function normalize($object, $format = null, array $context = [])
113113
$data['hydra:view']['hydra:previous'] = IriHelper::createIri($parsed['parts'], $parsed['parameters'], $this->pageParameterName, $currentPage - 1.);
114114
}
115115

116-
if (null !== $lastPage && $currentPage < $lastPage || null === $lastPage && $pageTotalItems >= $itemsPerPage) {
116+
if (null !== $lastPage && $currentPage < $lastPage || null === $lastPage && $pageTotalItems > $itemsPerPage) {
117117
$data['hydra:view']['hydra:next'] = IriHelper::createIri($parsed['parts'], $parsed['parameters'], $this->pageParameterName, $currentPage + 1.);
118118
}
119119
}

tests/Hydra/Serializer/PartialCollectionViewNormalizerTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ public function testNormalizePartialPaginator()
7979
'@id' => '/?_page=3',
8080
'@type' => 'hydra:PartialCollectionView',
8181
'hydra:previous' => '/?_page=2',
82-
'hydra:next' => '/?_page=4',
8382
],
8483
],
8584
$this->normalizePaginator(true)

0 commit comments

Comments
 (0)