Skip to content

Conversation

@duncanmcclean
Copy link
Member

@duncanmcclean duncanmcclean commented Apr 15, 2025

This pull request fixes an issue where the ->chunk() method on our query builder ignores any user-defined limits and offsets.

This meant that the following query would give you 10 chunks of 5 entries, rather than 2 chunks of 5 entries:

use Statamic\Facades\Entry;

Entry::query()
  ->where('collection', 'playground')
  ->limit(10)
  ->chunk(5, function ($entries) {
    dump($entries);
  });

This was fixed in Laravel 12, so I've copied over the fix (and the related test cases) in this PR. The Laravel PR has more context around the issue, and the fix.

Since this introduces a change in behaviour, this pull request is targeting the master branch.

Fixes #11698.

@jasonvarga jasonvarga merged commit 35625c8 into master Apr 15, 2025
21 checks passed
@jasonvarga jasonvarga deleted the fix/chunked-queries branch April 15, 2025 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants