Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix bug #67563: mysqli compiled with mysqlnd does not take ipv6 adress as parameter #19750

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

Open
nielsdos wants to merge 1 commit into php:PHP-8.3
base: PHP-8.3
Choose a base branch
Loading
from nielsdos:fix-67563

Conversation

Copy link
Member

@nielsdos nielsdos commented Sep 7, 2025

In the past, when libmysqlclient could be used, it accepted ipv6 addresses as hostname without enclosing it first in brackets. However, in mysqlnd this never worked. In the past this caused a discrepancy between the two implementations.
Nowadays, mysqli only works with mysqlnd so we don't even have to cater to libmysqlclient. However, a plain ipv6 address should still work as a hostname. Also for people migrating to newer PHP versions it's nice if this keeps working.

The solution is to check if we're dealing with an ipv6 address not yet enclosed in brackets. In that case we add the brackets automatically.


Testing this automatically seems not straight-forward. The connection string is not logged. Using the fake server requires modifications to specify a host and can't be easily reused in the same phpt file. This was tested by hand.

...s as parameter
In the past, when libmysqlclient could be used, it accepted ipv6 addresses
as hostname without enclosing it first in brackets. However, in mysqlnd
this never worked. In the past this caused a discrepancy between the two
implementations.
Nowadays, mysqli only works with mysqlnd so we don't even have to cater
to libmysqlclient. However, a plain ipv6 address should still work as a
hostname. Also for people migrating to newer PHP versions it's nice if
this keeps working.
The solution is to check if we're dealing with an ipv6 address not yet
enclosed in brackets. In that case we add the brackets automatically.
Copy link
Member

@kamil-tekiela kamil-tekiela left a comment

Choose a reason for hiding this comment

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

I am not going to test it but if you have tested that it works then you can merge it. I doubt anyone is using this feature, but in the future someone might.

How does this impact PDO? Is this a new feature in PDO too?

Copy link
Member Author

nielsdos commented Sep 7, 2025

How does this impact PDO? Is this a new feature in PDO too?

This should now also work properly in PDO-MYQSL, whereas previously it did not work.
I don't see it as a new feature though, the address that mysqlnd created was malformed so for me that's a bug 🙂

Copy link
Member

bukka commented Sep 10, 2025

The change looks good - nice and simple!

About the test, CI should support ::1 and think it's even resolving localhost to ::1 so why can't you add a test connection to ::1 (with maybe some grant update if needed)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@kamil-tekiela kamil-tekiela kamil-tekiela approved these changes

@bukka bukka Awaiting requested review from bukka bukka is a code owner

@SakiTakamachi SakiTakamachi Awaiting requested review from SakiTakamachi SakiTakamachi is a code owner

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /