Skip to content

fix: prevent extra query and invalid size in Model::chunk()#9961

Open
michalsn wants to merge 1 commit intocodeigniter4:developfrom
michalsn:fix/model-chunk
Open

fix: prevent extra query and invalid size in Model::chunk()#9961
michalsn wants to merge 1 commit intocodeigniter4:developfrom
michalsn:fix/model-chunk

Conversation

@michalsn
Copy link
Member

Description
This PR fixes a bug where Model::chunk() ran an unnecessary extra database query at the end of iteration.

Additionally, chunk() now throws InvalidArgumentException when called with a chunk size of zero or less. Previously, passing 0 as the size would silently interact with the Config\Feature::limitZeroAsAll feature flag, potentially converting LIMIT 0 into an unlimited query and loading the entire table into memory at once.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value (without duplication)
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@michalsn michalsn added the bug Verified issues on the current code behavior or pull requests that will fix them label Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Verified issues on the current code behavior or pull requests that will fix them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments