Skip to content

Chunked queries ignore user-defined limits and offsets #11698

@aerni

Description

@aerni

Bug description

If you chunk a query it will ignore user-defined limits and offsets. Let's say we've got 50 entries. The query below would return 10 chunks of 5 entries. But I'm expecting to get 2 chunks of 5 entries, as I've set a limit of 10.

Entry::query()
    ->limit(10)
    ->chunk(5, function($entries) {
        //
    });

This seems to be a long-standing issue with chunking in Laravel. There's been a PR that fixed the issue for Laravel 12. Maybe it can be used to fix the issue with Statamic content queries as well.

How to reproduce

Create a few dummy entries and use the query above.

Logs

Environment

Environment
Application Name: Statamic
Laravel Version: 12.8.1
PHP Version: 8.3.20
Composer Version: 2.8.6
Environment: local
Debug Mode: ENABLED
URL: komm.test
Maintenance Mode: OFF
Timezone: UTC
Locale: en

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: file
Database: sqlite
Logs: stack / single
Mail: log
Queue: sync
Session: file

Storage
public/storage: NOT LINKED

Livewire
Livewire: v3.6.2

Statamic
Addons: 3
Sites: 1
Stache Watcher: Enabled (auto)
Static Caching: Disabled
Version: 5.53.0 PRO

Statamic Addons
aerni/factory: dev-feature/refactor
marcorieser/statamic-livewire: 4.4.1
stillat/antlers-components: 2.6.0

Installation

Fresh statamic/statamic site via CLI

Additional details

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions