-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
PDO: Raise a proper exception if user or password is false #6513
Conversation
0f38b9a
to
7773849
Compare
public static function notAStringOrNull(string $key, mixed $value): self | ||
{ | ||
return new self(sprintf( | ||
'The %s configuration setting is expected to be either a string or null, got %s.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd use "configuration parameter" instead of "configuration setting" for consistency with the existing terminology. We use "params" / "parameters" a lot at least in the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. I've adjusted the wording.
7773849
to
3357e98
Compare
3357e98
to
4363ac6
Compare
* 4.1.x: PDO: Raise a proper exception if user or password is false (#6513)
* 4.2.x: PDO: Raise a proper exception if user or password is false (#6513)
Summary
If
false
(or anything that is not a string) is passed asuser
orpassword
, we run into aTypeError
because we pass that value as-is to the constructor of PDO. This started to happen after we enabled strict types on our driver classes in 4.0.On 3.9,
false
would implicitly be cast to an empty string which is either desired or leads to more obscure connection errors. We could restore the behavior of 3.9 by adding explicit type casts to the two parameters. But since we don't documentfalse
as a valid value for either parameter, my preference would indeed be raising an exception.