Skip to content

Commit

Permalink
[5.x] Fix cannot use paginate/limit error when one is null (#11478)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksleight authored Feb 21, 2025
1 parent 9054201 commit afd32e8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Tags/Concerns/GetsQueryResults.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
}

Expand Down
13 changes: 13 additions & 0 deletions tests/Tags/Collection/EntriesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down

0 comments on commit afd32e8

Please sign in to comment.