Skip to content

Conversation

nielsdos
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.
@nielsdos nielsdos changed the base branch from master to PHP-8.3 September 7, 2025 19:12
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?

@nielsdos
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 🙂

@bukka
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants