Skip to content

Fix GH-25650: PDO::query() reports wrong argument numbers for ctor args - #25651

Closed
thunderer wants to merge 1 commit into
php:PHP-8.5from
thunderer:fix/pdo-query-ctor-args-arg-num
Closed

thunderer wants to merge 1 commit into
php:PHP-8.5from
thunderer:fix/pdo-query-ctor-args-arg-num

Conversation

@thunderer

Copy link
Copy Markdown
Contributor

Fixes GH-25650.

pdo_stmt_setup_fetch_mode() hardcodes argument 3 and argument #2 in the error for constructor arguments passed with a class that has no constructor. That is only right for PDOStatement::setFetchMode(). PDO::query() passes the fetch mode as argument 2, so it reported the class as argument #2 and the constructor arguments as argument #3. The fix uses the computed constructor_arg_num and arg1_arg_num, like the other errors in the same function.

The test adds the PDO::query() case to pdo_stmt_class_ctor_errors.phpt, next to the existing fetchAll() and setFetchMode() cases, which do not change.

PHP 8.4 is not affected, so this targets PHP-8.5.

The quoted paragraphs were drafted with an LLM.

… args

pdo_stmt_setup_fetch_mode() hardcoded argument 3 and argument php#2 in the
error for constructor arguments passed with a class that has no
constructor. That is only right for PDOStatement::setFetchMode().
PDO::query() passes the fetch mode as argument 2, so use the computed
constructor_arg_num and arg1_arg_num instead.

@kamil-tekiela kamil-tekiela left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

@thunderer
thunderer deleted the fix/pdo-query-ctor-args-arg-num branch November 24, 2026 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants