ID: 49965
Updated by: uw@php.net
Reported By: ed at bellcpa dot com
-Status: Assigned
+Status: Closed
Bug Type: MySQLi related
Operating System: *
PHP Version: 5.*, 6.*
Assigned To: mysql
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:
------------------------------------------------------------------------
[2009-11-03 14:56:04] svn@php.net
Automatic comment from SVN on behalf of uw
Revision: http://svn.php.net/viewvc/?view=revision&revision=290170
Log: Fix for bug #49965 . Let mysqli_options() try to cast option
values to the appropriate type.
------------------------------------------------------------------------
[2009-10-29 18:19:45] uw@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] uw@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] uw@php.net
Interesting. I assume it does not matter if you use 5.3.0 or
5.3.2-dev?
Thanks so far!
Ulf
------------------------------------------------------------------------
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