Skip to content

fix: clear bindings when resetting compiled queries - #10692

Merged
paulbalandan merged 1 commit into
codeigniter4:4.8from
michalsn:fix/bindings-48
Oct 31, 2026
Merged

paulbalandan merged 1 commit into
codeigniter4:4.8from
michalsn:fix/bindings-48

Conversation

@michalsn

Copy link
Copy Markdown
Member

Description
This PR fixes a bug where compiled queries retain old bindings after you reset the Query Builder, causing bindings to accumulate and compilation to become increasingly expensive when you reuse the same builder.

Bindings and binding counters are now cleared after compiling SELECT, INSERT, UPDATE, and DELETE queries with $reset = true. Passing $reset = false preserves the query and its bindings.

Although the user guide already states that getCompiledSelect() should reset the builder just like get(), this changes observable behavior: getBinds() now returns an empty array after compilation with reset enabled. Therefore this targets 4.8 rather than the develop branch and includes a breaking-change entry and migration instructions.

Fixes #10691

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 bug Verified issues on the current code behavior or pull requests that will fix them 4.8 PRs that target the `4.8` branch. labels Oct 30, 2026
@paulbalandan

paulbalandan commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

It seems delete() and countAllResults() exhibit the same binds leak. But can be for another issue/PR.

@michalsn

Copy link
Copy Markdown
Member Author

Seems right - thanks. I will prepare a follow-up later today.

@paulbalandan
paulbalandan merged commit 0094803 into codeigniter4:4.8 Oct 31, 2026
61 checks passed
@paulbalandan

Copy link
Copy Markdown
Member

Thank you, @michalsn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.8 PRs that target the `4.8` branch. 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.

Bug: getCompiledSelect() does not clear $binds, so a reused builder gets slower on every call

2 participants