Bug #74432 [Asn]: mysqli_connect adding ":3306" to $host if $port parameter not given
| From: | pollita@php.net | Date: | Thu, 20 Apr 2017 17:08:07 +0000 |
| Subject: | Bug #74432 [Asn]: mysqli_connect adding ":3306" to $host if $port parameter not given | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-208693@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74432&edit=1
ID: 74432
Updated by: pollita@php.net
Reported by: php dot bugs at harry dot lu
Summary: mysqli_connect adding ":3306" to $host if $port
parameter not given
Status: Assigned
Type: Bug
Package: MySQLi related
Operating System: Linux x86_64
PHP Version: 7.0.18
Assigned To: pollita
Block user comment: N
Private report: N
New Comment:
dig dig dig...
So, this may only be happening to mysqli_connect() if mysqlnd is enabled (which is typical), though
in the mysqlnd enabled case it looks like you can't actually use an IPv6 address unless you
explicitly wrap it in square brackets.
This rabbit hole keeps getting deeper. :(
Previous Comments:
------------------------------------------------------------------------
[2017-04-20 15:32:27] pollita@php.net
Oh, and as to predis, that's a bug in predis appending ":$port" when $port
doesn't actually contain any value. Someone should send a pull request regarding these lines:
https://github.com/nrk/predis/blob/6ab10b2b705ea5121f2c1ea87a290f6871c32ebd/src/Connection/StreamConnection.php#L156-L160
------------------------------------------------------------------------
[2017-04-20 15:20:13] pollita@php.net
OMG. Why is every use of streams wrong?
Yeah, I'll clean mysqli_connect() up for the "port parameter not used" case.
------------------------------------------------------------------------
[2017-04-19 09:06:26] premavansmuuf at gmail dot com
I _think_ I am having somehow similar problem when using Predis, where I have port defined inside
$host variable instead of having it separately in $port.
Failed to parse address "localhost:6379:" [tcp://localhost:6379:]
Predis is using stream_socket_client() function.
It works in 5.6 but I think it stopped working in new PHP 7 version.
------------------------------------------------------------------------
[2017-04-14 13:16:58] ab@php.net
Sara, could you please check? Seems there might be other regressions related to #74216.
Thanks.
------------------------------------------------------------------------
[2017-04-13 11:23:34] php dot bugs at harry dot lu
Description:
------------
Hello,
This seems to be a regression in 7.0.18. If you give a port in the $host section of mysqli_connect,
it will still add ":3306" to the end of it.
> mysqli_connect("127.0.0.1:3306", "user", "pass",
> "schema");
will return:
> mysqli_connect(): (HY000/2002): Failed to parse address "127.0.0.1:3306:3306"
Notice the double port assignment. People should be using the $port parameter if mysqli_connect and
not giving ports like this, but it still seems like a regression to me. Thanks!
Test script:
---------------
<?php
# Works in 7.0.17, broken in 7.0.18
mysqli_connect("127.0.0.1:3306", "user", "pass", "schema");
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74432&edit=1