diff --git a/src/Tags/Concerns/GetsQueryResults.php b/src/Tags/Concerns/GetsQueryResults.php index 766b8b2290..0e67046dc6 100644 --- a/src/Tags/Concerns/GetsQueryResults.php +++ b/src/Tags/Concerns/GetsQueryResults.php @@ -44,7 +44,7 @@ protected function allowLegacyStylePaginationLimiting() protected function preventIncompatiblePaginationParameters() { - if ($this->params->int('paginate') && $this->params->has('limit')) { + if ($this->params->int('paginate') && $this->params->int('limit')) { throw new \Exception('Cannot use [paginate] integer in combination with [limit] param.'); } diff --git a/tests/Tags/Collection/EntriesTest.php b/tests/Tags/Collection/EntriesTest.php index 96b6b3d9f8..603f6bae49 100644 --- a/tests/Tags/Collection/EntriesTest.php +++ b/tests/Tags/Collection/EntriesTest.php @@ -142,6 +142,19 @@ public function it_should_throw_exception_if_trying_to_paginate_and_limit_at_sam $this->assertCount(3, $this->getEntries(['paginate' => 3, 'limit' => 4])); } + #[Test] + public function it_should_not_throw_exception_if_trying_to_paginate_or_limit_and_the_other_is_null() + { + $this->makeEntry('a')->save(); + $this->makeEntry('b')->save(); + $this->makeEntry('c')->save(); + $this->makeEntry('d')->save(); + $this->makeEntry('e')->save(); + + $this->assertCount(3, $this->getEntries(['paginate' => 3, 'limit' => null])); + $this->assertCount(3, $this->getEntries(['paginate' => null, 'limit' => 3])); + } + #[Test] public function it_should_throw_exception_if_trying_to_paginate_and_chunk_at_same_time() {