Skip to content

pdo: report correct argument number for constructor option errors - #257

Open
iliaal wants to merge 1 commit into
PHP-8.5from
fix/aph-hw9-85
Open

pdo: report correct argument number for constructor option errors#257
iliaal wants to merge 1 commit into
PHP-8.5from
fix/aph-hw9-85

Conversation

@iliaal

@iliaal iliaal commented Aug 24, 2026

Copy link
Copy Markdown
Owner

When an attribute passed through the PDO constructor options array failed to set, the resulting error message named argument #3 ($password) instead of argument #4 ($options), because pdo_dbh_attribute_set() was called from php_pdo_internal_construct_driver() with a hardcoded value_arg_num of 3. This passes 4 so errors like an invalid PDO::ATTR_ERRMODE now correctly report Argument #4 ($options). The only other caller, PDO::setAttribute(), already passes the correct number and was audited; a test asserting the corrected message is included and fails without the patch.

When an attribute from the PDO constructor options array fails to set,
the error named $password (argument #3) instead of $options
(argument #4). Sibling call sites of pdo_dbh_attribute_set() audited;
PDO::setAttribute() already passes the correct number.
@iliaal iliaal closed this Aug 24, 2026
@iliaal iliaal reopened this Aug 24, 2026
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