Bug #70389 [Opn->Csd]: PDO constructor changes unrelated variables
| From: | laruence@php.net | Date: | Sun, 30 Aug 2015 12:33:46 +0000 |
| Subject: | Bug #70389 [Opn->Csd]: PDO constructor changes unrelated variables | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-195614@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70389&edit=1
ID: 70389
Updated by: laruence@php.net
Reported by: remyfox at hotmail dot com
Summary: PDO constructor changes unrelated variables
-Status: Open
+Status: Closed
Type: Bug
Package: PDO related
Operating System: Windows
PHP Version: 5.6.12
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=ef1bd8f0e6f88b1d123cea1c0b5079cfde7f90df
Log: Fixed bug #70389 (PDO constructor changes unrelated variables)
Previous Comments:
------------------------------------------------------------------------
[2015-08-29 15:43:30] remyfox at hotmail dot com
Description:
------------
It turns out that the fourth parameter (I haven't verified for the others) appears to function
"on reference"; i.e. it changes the variable types of set flags from booleans into
integers. But what's more, it also changes the variable types on unrelated variables as well.
Test script:
---------------
$dsn = "mysql:host=127.0.0.1;dbname=application_base";
$user = "root";
$password = "";
$flags = [
PDO::MYSQL_ATTR_FOUND_ROWS => true,
PDO::MYSQL_ATTR_LOCAL_INFILE => true
];
$std = new StdClass();
$std->flags = $flags;
// The values are still booleans.
var_dump($flags);
new PDO($dsn, $user, $password, $flags);
// Booleans have turned into integers (as if the $flags parameter is on reference, which would be
undocumented).
var_dump($flags);
// Booleans have ALSO turned into integers! Which does not make sense, even if the $flags parameter
had been on reference.
var_dump($std->flags);
Expected result:
----------------
The array in the last two var dumps only contains booleans, not integers.
Actual result:
--------------
The array in the last two var dumps suddenly converted both integers into booleans and there is no
way to work around that.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70389&edit=1