Skip to content
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

Do not require hostname for non-persistent MySQL connection and require for persistent #3943

Merged
merged 1 commit into from
Apr 11, 2020

Conversation

morozov
Copy link
Member

@morozov morozov commented Apr 11, 2020

Q A
Type bug
BC Break no

Fixes #3942.

According to the documentation, the hostname may be omitted and will default to "localhost". However, given the fact that the persistent connection flag is passed as part of the hostname, the hostname cannot be omitted for persistent connection.

The issue is not reproducible on 2.x because the "Undefined index" notice is suppressed by the error handler:

set_error_handler(static function () {
});
try {
if (! $this->conn->real_connect($params['host'], $username, $password, $dbname, $port, $socket, $flags)) {

namespace Doctrine\DBAL\Driver\Mysqli;

/**
* @internal
Copy link
Member Author

Choose a reason for hiding this comment

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

Also, note that I marked it as @internal (there's a plan to do the same for the rest of the named exceptions in newer versions). This way, we can rework them at any time w/o breaking other's code who should rely only on higher-level classes and interfaces.

@morozov morozov merged commit e27d655 into doctrine:3.0.x Apr 11, 2020
@morozov morozov deleted the issues/3942 branch April 11, 2020 16:40
@morozov morozov self-assigned this Apr 12, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MySQLi connection fails or triggers a notice if the hostname is not specified
2 participants