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

From: Date: Sat, 13 Feb 2016 12:23:28 +0000
Subject: Bug #70389 [Com]: PDO constructor changes unrelated variables
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-199189@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 Comment by: pavel2000 at ngs dot ru Reported by: remyfox at hotmail dot com Summary: PDO constructor changes unrelated variables Status: Closed Type: Bug Package: PDO related Operating System: Windows PHP Version: 5.6.12 Block user comment: N Private report: N New Comment: Hi! We found that resolution of this bug by http://git.php.net/?p=php-src.git;a=commit;h=ef1bd8f0e6f88b1d123cea1c0b5079cfde7f90df introduces regression and crashes. Please look into #71569 for details and proposed solution. Thanks. Previous Comments: ------------------------------------------------------------------------ [2015-09-03 18:10:26] ab@php.net 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) ------------------------------------------------------------------------ [2015-08-30 12:34:23] laruence@php.net 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) ------------------------------------------------------------------------ [2015-08-30 12:33:45] laruence@php.net 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) ------------------------------------------------------------------------ [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

« previous php.bugs (#199189) next »