-
Notifications
You must be signed in to change notification settings - Fork 7.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle invalid index passed to PDOStatement::fetchColumn() as error #3655
Conversation
cc @cjbj, shouldn't PDO itself check this before dispatching to the column fetcher tho? |
To the @KalleZ's point, the same issue may exist in |
@KalleZ did you have something like master...morozov:bug77118-alt in mind? |
@morozov yeah that was something like it I was thinking, that way we don't need to update all drivers (and database vendors don't need to do it either). But it needs some more input from people who are more familiar with PDO internals than I am, I'm afraid. |
Why should trying to fetch an invalid column be silently ignored? |
I agree with @nikic - an error should occur. Also, shouldn't the PR's test be generic, since the fix is generic? |
For consistency of the behavior with other PDO drivers (MySQL, SQLite, PostgreSQL). However, the documentation doesn't specify any behavior in this case. |
Is it acceptable to trigger/throw an error in PHP 7? The test is not generic because the original fix was not generic. |
The documented behavior for all of the PDO fetch methods is to return false on a failure. PDO can trigger warnings or exceptions, but that behavior is user-specified. There aren't a lot of documented (or de facto) patterns for when errors should be triggered. It certainly feels right that this is an error state. But this should only be committed to master since that's a new behavior. Applications might not be expecting this, even if it feels like a minor nuance. What I would expect here:
I can run the test suite with pdo_dblib after this is updated. Agree the added test should be part of the common suite. |
@adambaratz thank you for the suggestion. I'll try to implement as soon as I have some spare time. |
@adambaratz please see the update. |
Comment on behalf of adambaratz at php.net: Merged into master, branches for 7.2 and 7.3. I saw a similar change make it in as a bug fix so did the same here. Thanks for cleaning this up! |
Fixes bug #77118.