Edit report at http://bugs.php.net/bug.php?id=51242&edit=1

 ID:          51242
 Updated by:  [email protected]
 Reported by: php-bugs at thequod dot de
 Summary:     Empty mysql.default_port does not default to 3306 anymore,
              but 0
-Status:      Assigned
+Status:      Closed
 Type:        Bug
 Package:     MySQL related
 PHP Version: 5.3.2
 Assigned To: aharvey

 New Comment:

This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.




Previous Comments:
------------------------------------------------------------------------
[2010-03-09 06:08:33] [email protected]

Automatic comment from SVN on behalf of aharvey
Revision: http://svn.php.net/viewvc/?view=revision&revision=295982
Log: Fixed bug #51242 (Empty mysql.default_port does not default to 3306
anymore, but 0).

------------------------------------------------------------------------
[2010-03-09 05:20:50] [email protected]

I can reproduce this with a current, unpatched PHP_5_3 build. It does
require an 

unusual and rather specific set of circumstances, though:



1. PHP has to be configured with --with-mysql-sock set and mysqlnd
support.

2. mysql.default_port= must be in a configuration file without a value.

3. mysql_connect() must be called without a port specified.



Effectively, the empty string for the port setting gets converted by the
atoi() 

call in OnMySQLPort to 0, which results in mysqlnd's connect method
being called 

with port = 0. Said connect method has a test where the port is set to
3306 if 

both the port and socket aren't specified. In this case, of course, the
socket 

is specified, even though it's unused, and hence the port number never
gets 

reset.



This works with an external libmysqlclient because mysql_real_connect()
handles 

the port being 0.



Fix forthcoming shortly, once I've satisfied myself it doesn't break
anything 

else.

------------------------------------------------------------------------
[2010-03-09 00:54:48] php-bugs at thequod dot de

TML could not reproduce this on ##php:



php -d mysql.default_port="" -r '$db = mysql_connect("127.0.0.1") or 

die(mysql_error()); var_dump($db);'



I can (although using another IP).



The difference is also that I'm using the Suhosin patch (via dotdeb.org)
and TML 

is not.

------------------------------------------------------------------------
[2010-03-09 00:33:35] php-bugs at thequod dot de

Description:
------------
I've upgraded a server to PHP 5.3.2 (from dotdeb.org), and got
"Connection 

refused" errors from mysql_connect.



The cause was that I've not specified a port with $host, and PHP used
"0" 

apparently:

  Connection refused (trying to connect via tcp://10.122.42.42:0)



I have “mysql.default_port = ” in the ini file, which is the default
(I assume), 

and it defaulted to 3306 then previously (5.3.1 from dotdeb), but not
anymore.



------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=51242&edit=1

Reply via email to