Skip to content

Fix bindParametersFromContainer() to prevent invalid parameter name characters#137

Merged
simon-mundy merged 1 commit intophp-db:0.6.xfrom
simon-mundy:fix-invalid-parameter-name
Feb 25, 2026
Merged

Fix bindParametersFromContainer() to prevent invalid parameter name characters#137
simon-mundy merged 1 commit intophp-db:0.6.xfrom
simon-mundy:fix-invalid-parameter-name

Conversation

@simon-mundy
Copy link
Collaborator

@simon-mundy simon-mundy commented Feb 25, 2026

Q A
Documentation no
Bugfix yes
BC Break no
New Feature no
RFC no
QA yes
House Keeping yes

Description

A test from phpdb-mysql in PhpDbIntegrationTest\Mysql\Pdo\QueryTest called testSelectWithNotPermittedBindParamName was marked 'incomplete' but in reality it belongs in the core package.

The validation already exists in the vendor package at AbstractPdo::formatParameterName() (line 146: /[^a-zA-Z0-9_]/), but it's only called from the SQL builder path — never for raw queries.

The problem is that the PDO Statement::bindParametersFromContainer() at src/Adapter/Driver/Pdo/Statement.php:227 constructs the parameter name and passes it straight to PDO::bindParam() without validating it. PDO silently accepts invalid characters like $.

This fixes the issue right within the Statement at bindParametersFromContainer just before the params hit the PDO resource.

…PermittedBindParamName

New unit tests for Base Parameter Container

Signed-off-by: Simon Mundy <simon.mundy@peptolab.com>
@simon-mundy simon-mundy self-assigned this Feb 25, 2026
@simon-mundy simon-mundy changed the title Moved functionality from phpdb-mysql Pdo\QueryTest::testSelectWithNot… Fix bindParametersFromContainer() to prevent invalid parameter name characters Feb 25, 2026
@simon-mundy simon-mundy added enhancement New feature or request qa Improvements in quality assurance of the project Platform migration Changes related to platform migrations labels Feb 25, 2026
@github-project-automation github-project-automation bot moved this to Todo in @phpdb Feb 25, 2026
@simon-mundy simon-mundy added this to the 0.6.0 milestone Feb 25, 2026
@simon-mundy simon-mundy merged commit cb328d3 into php-db:0.6.x Feb 25, 2026
13 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in @phpdb Feb 25, 2026
@simon-mundy simon-mundy deleted the fix-invalid-parameter-name branch February 27, 2026 01:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Platform migration Changes related to platform migrations qa Improvements in quality assurance of the project

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant