php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70389 PDO constructor changes unrelated variables
Submitted: 2015-08-29 15:43 UTC Modified: -
From: remyfox at hotmail dot com Assigned:
Status: Closed Package: PDO related
PHP Version: 5.6.12 OS: Windows
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: remyfox at hotmail dot com
New email:
PHP Version: OS:

 

 [2015-08-29 15:43 UTC] 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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-08-30 12:33 UTC] 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 UTC] laruence@php.net
-Status: Open +Status: Closed
 [2015-08-30 12:34 UTC] 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-09-03 18:10 UTC] 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)
 [2016-02-13 12:23 UTC] pavel2000 at ngs dot ru
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 18:01:29 2024 UTC