From c7a706382c365a2cacedfa2b463d68ca929b40cd Mon Sep 17 00:00:00 2001 From: Lothar Serra Mari Date: Sat, 13 Dec 2025 20:35:35 +0100 Subject: [PATCH] dev-lang/php: backport GH-20528 MySQL connections are broken when using an IPv6 address enclosed in square brackets. Closes: https://github.com/gentoo/gentoo/pull/45016 Signed-off-by: Lothar Serra Mari Signed-off-by: Michael Orlitzky --- dev-lang/php/files/php-gh-20528-fix.patch | 81 +++++++++++++++++++ ...php-8.3.28.ebuild => php-8.3.28-r1.ebuild} | 1 + ...php-8.4.15.ebuild => php-8.4.15-r1.ebuild} | 1 + .../{php-8.5.0.ebuild => php-8.5.0-r1.ebuild} | 1 + 4 files changed, 84 insertions(+) create mode 100644 dev-lang/php/files/php-gh-20528-fix.patch rename dev-lang/php/{php-8.3.28.ebuild => php-8.3.28-r1.ebuild} (99%) rename dev-lang/php/{php-8.4.15.ebuild => php-8.4.15-r1.ebuild} (99%) rename dev-lang/php/{php-8.5.0.ebuild => php-8.5.0-r1.ebuild} (99%) diff --git a/dev-lang/php/files/php-gh-20528-fix.patch b/dev-lang/php/files/php-gh-20528-fix.patch new file mode 100644 index 0000000000000..f8a790a48acd5 --- /dev/null +++ b/dev-lang/php/files/php-gh-20528-fix.patch @@ -0,0 +1,81 @@ +From 9d71c1e0b60cd152a47528dbe514efc443fce920 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Thu, 20 Nov 2025 02:58:45 +0100 +Subject: [PATCH] Fix GH-20528: Regression breaks mysql connexion using an IPv6 + address enclosed in square brackets + +--- + ext/mysqli/tests/mysqli_connect_port.phpt | 31 +++++++++++++++++++++++ + ext/mysqlnd/mysqlnd_connection.c | 17 ++++++++++--- + 2 files changed, 45 insertions(+), 3 deletions(-) + create mode 100644 ext/mysqli/tests/mysqli_connect_port.phpt + +diff --git a/ext/mysqli/tests/mysqli_connect_port.phpt b/ext/mysqli/tests/mysqli_connect_port.phpt +new file mode 100644 +index 0000000000000..cb7fd1d8d1628 +--- /dev/null ++++ b/ext/mysqli/tests/mysqli_connect_port.phpt +@@ -0,0 +1,31 @@ ++--TEST-- ++mysqli_connect() with port in host ++--EXTENSIONS-- ++mysqli ++--SKIPIF-- ++ ++--FILE-- ++ ++Done ++--EXPECTF-- ++Done +diff --git a/ext/mysqlnd/mysqlnd_connection.c b/ext/mysqlnd/mysqlnd_connection.c +index d8e7304e9665f..8268034e8b798 100644 +--- a/ext/mysqlnd/mysqlnd_connection.c ++++ b/ext/mysqlnd/mysqlnd_connection.c +@@ -553,13 +553,24 @@ MYSQLND_METHOD(mysqlnd_conn_data, get_scheme)(MYSQLND_CONN_DATA * conn, MYSQLND_ + port = 3306; + } + +- /* ipv6 addresses are in the format [address]:port */ + if (hostname.s[0] != '[' && mysqlnd_fast_is_ipv6_address(hostname.s)) { ++ /* IPv6 without square brackets so without port */ + transport.l = mnd_sprintf(&transport.s, 0, "tcp://[%s]:%u", hostname.s, port); + } else { +- /* Not ipv6, but could already contain a port number, in which case we should not add an extra port. ++ char *p; ++ ++ /* IPv6 addresses are in the format [address]:port */ ++ if (hostname.s[0] == '[') { /* IPv6 */ ++ p = strchr(hostname.s, ']'); ++ if (p && p[1] != ':') { ++ p = NULL; ++ } ++ } else { /* IPv4 or name */ ++ p = strchr(hostname.s, ':'); ++ } ++ /* Could already contain a port number, in which case we should not add an extra port. + * See GH-8978. In a port doubling scenario, the first port would be used so we do the same to keep BC. */ +- if (strchr(hostname.s, ':')) { ++ if (p) { + /* TODO: Ideally we should be able to get rid of this workaround in the future. */ + transport.l = mnd_sprintf(&transport.s, 0, "tcp://%s", hostname.s); + } else { diff --git a/dev-lang/php/php-8.3.28.ebuild b/dev-lang/php/php-8.3.28-r1.ebuild similarity index 99% rename from dev-lang/php/php-8.3.28.ebuild rename to dev-lang/php/php-8.3.28-r1.ebuild index 0ae2bc9a6cb12..eeb2d83be1e74 100644 --- a/dev-lang/php/php-8.3.28.ebuild +++ b/dev-lang/php/php-8.3.28-r1.ebuild @@ -136,6 +136,7 @@ BDEPEND="virtual/pkgconfig" PATCHES=( "${FILESDIR}/php-8.3.9-gd-cachevars.patch" "${FILESDIR}/php-8.4.14-libpcre2-testfix.patch" + "${FILESDIR}/php-gh-20528-fix.patch" ) PHP_MV="$(ver_cut 1)" diff --git a/dev-lang/php/php-8.4.15.ebuild b/dev-lang/php/php-8.4.15-r1.ebuild similarity index 99% rename from dev-lang/php/php-8.4.15.ebuild rename to dev-lang/php/php-8.4.15-r1.ebuild index 507a6e9e5a0d8..4bd782790454f 100644 --- a/dev-lang/php/php-8.4.15.ebuild +++ b/dev-lang/php/php-8.4.15-r1.ebuild @@ -133,6 +133,7 @@ BDEPEND="virtual/pkgconfig" PATCHES=( "${FILESDIR}/php-8.4.14-libpcre2-testfix.patch" + "${FILESDIR}/php-gh-20528-fix.patch" ) PHP_MV="$(ver_cut 1)" diff --git a/dev-lang/php/php-8.5.0.ebuild b/dev-lang/php/php-8.5.0-r1.ebuild similarity index 99% rename from dev-lang/php/php-8.5.0.ebuild rename to dev-lang/php/php-8.5.0-r1.ebuild index 2bbf0915086c5..361726f19417a 100644 --- a/dev-lang/php/php-8.5.0.ebuild +++ b/dev-lang/php/php-8.5.0-r1.ebuild @@ -133,6 +133,7 @@ BDEPEND="virtual/pkgconfig" PATCHES=( "${FILESDIR}/php-8.4.14-libpcre2-testfix.patch" + "${FILESDIR}/php-gh-20528-fix.patch" ) PHP_MV="$(ver_cut 1)"