Bug #70389 [NEW]: PDO constructor changes unrelated variables

From: Date: Sat, 29 Aug 2015 15:43:31 +0000
Subject: Bug #70389 [NEW]: PDO constructor changes unrelated variables
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-195624@lists.php.net to get a copy of this message
From: remyfox at hotmail dot com Operating system: Windows PHP version: 5.6.12 Package: PDO related Bug Type: Bug Bug description:PDO constructor changes unrelated variables 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 bug report at https://bugs.php.net/bug.php?id=70389&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70389&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70389&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70389&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=70389&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=70389&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=70389&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=70389&r=needscript Try newer version: https://bugs.php.net/fix.php?id=70389&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=70389&r=support Expected behavior: https://bugs.php.net/fix.php?id=70389&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=70389&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=70389&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=70389&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70389&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=70389&r=dst IIS Stability: https://bugs.php.net/fix.php?id=70389&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=70389&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=70389&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=70389&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=70389&r=mysqlcfg

« previous php.bugs (#195624) next »