Skip to content

Query: substitute bound values in a single pass - #10

Merged
daedeloth merged 1 commit into
masterfrom
fix/query-single-pass-substitution
Oct 7, 2026
Merged

daedeloth merged 1 commit into
masterfrom
fix/query-single-pass-substitution

Conversation

@daedeloth

Copy link
Copy Markdown
Member

What changes

Query::getParsedQuery() put a fixed marker where each value goes and then substituted the values one after another over the whole query. A value is data and must never be read as part of the query's own structure, but text inside one value could be taken for the marker of another.

Now all markers are swapped for their values in one strtr() pass, which never rescans text it has already substituted, and the markers carry a random part per query.

No change for callers: the same queries come out for the same input.

Tests

  • New: a value containing marker-like text stays a literal, in both new Query(...) with bound values and the select builder, for positional and named placeholders; a later value appears exactly once in the result.
  • phpunit --exclude-group=database (the CI selection), run locally on PHP 8.5: 203 tests, 3 errors. The 3 errors are the MySQLErrorTest cases, which need the mysqli extension my local PHP lacks; they error the same way on master.

Release

Intended for 3.3.1, together with #9.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DqZUi2UiBJP6rZoCSRcdpE

Values were substituted one after another over the whole query, through
fixed marker strings. Text inside one value could therefore be taken
for the marker of another. All markers are now swapped for their values
in one strtr() pass that never rescans substituted text, and markers
carry a random part per query.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DqZUi2UiBJP6rZoCSRcdpE
@daedeloth
daedeloth merged commit e9b8fa5 into master Oct 7, 2026
5 checks passed
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.

1 participant