ID:               49965
 Updated by:       j...@php.net
 Reported By:      ed at bellcpa dot com
-Status:           Open
+Status:           Assigned
 Bug Type:         MySQLi related
-Operating System: any
+Operating System: *
 PHP Version:      5.*, 6.*
 Assigned To:      mysql


Previous Comments:
------------------------------------------------------------------------

[2009-10-29 18:19:45] u...@php.net

I discussed this with Andrey. We propose to change ext/mysqli to cast
$value passed to mysqli_options to an appropriate type internally. Old
code should not notice the change because it should be using an
appropriate type for $value in mysqli_options($link, $option, $value)
already.

I'll soon patch ext/mysqli.



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

[2009-10-28 23:58:12] ed at bellcpa dot com

Ah, makes perfect sense. Glad it wasn't something more serious and
sorry for the oversight. Enclosing my option value in intval() solved it
as expected.

Thanks!

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

[2009-10-28 23:48:10] u...@php.net

Hi Ed,

thanks for the additional information given in a private mail.

Yes, it matters what type the option value has that you pass to
mysqli_options(). It matters ever since 5.0. It is irrelevant if you use
mysqlnd or libmysql.

mysqli_options(mysqli $link, int $option, mixed $value) inspects the
type of the $value parameter. If you pass a string value, as stated in
your private mail, ext/mysqli forwards a string to mysqlnd resp.
libmysql. Both mysqlnd and libmysql expect that the data they get is of
the appropriate type for $option allowing them to use a simple cast to
interpret the data. 

String is not the appropriate type for MYSQLI_OPT_CONNECT_TIMEOUT - the
cast inside mysqlnd/libmysql causes a bogus value to be used...

This will not work:

 $timeout = "5"
 mysqli_options($link, MYSQLI_OPT_CONNECT_TIMEOUT, $timeout);
 mysqli_options($link, MYSQLI_OPT_CONNECT_TIMEOUT, "5");

You must use the following:

 $timeout = 5;
 mysqli_options($link, MYSQLI_OPT_CONNECT_TIMEOUT, $timeout);
 mysqli_options($link, MYSQLI_OPT_CONNECT_TIMEOUT, 5);



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

[2009-10-28 17:52:26] u...@php.net

Interesting. I assume it does not matter if you use 5.3.0 or
5.3.2-dev?

Thanks so far!
Ulf

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

[2009-10-28 17:40:27] ed at bellcpa dot com

Ulf,

Here is the fsockopen() result, looks like timeout works as expected:

C:\temp2>php testme.php
PHP Warning:  fsockopen(): unable to connect to
tcp://192.168.201.222:3306 (A co
nnection attempt failed because the connected party did not properly
respond aft
er a period of time, or established connection failed because connected
host has
 failed to respond.
) in C:\temp2\testme.php on line 6
PHP Stack trace:
PHP   1. {main}() C:\temp2\testme.php:0
PHP   2. fsockopen() C:\temp2\testme.php:6

Warning: fsockopen(): unable to connect to tcp://192.168.201.222:3306
(A connect
ion attempt failed because the connected party did not properly respond
after a
period of time, or established connection failed because connected host
has fail
ed to respond.
) in C:\temp2\testme.php on line 6

Call Stack:
    0.0312     324832   1. {main}() C:\temp2\testme.php:0
    0.0491     325280   2. fsockopen() C:\temp2\testme.php:6

bool(false)
int(10060)
string(185) "A connection attempt failed because the connected party
did not pro
perly respond after a period of time, or established connection failed
because c
onnected host has failed to respond.
"
float(5.1100761890411)

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

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/49965

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

Reply via email to