php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73474 Fatal error: PDO::__construct(): out of memory
Submitted: 2016-11-07 12:08 UTC Modified: 2017-10-24 08:31 UTC
Votes:3
Avg. Score:4.7 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:2 (66.7%)
From: hetao at hetao dot name Assigned:
Status: Open Package: PDO related
PHP Version: PHP Version 5.6.27-1+deb.sury.org~xenial+1 OS: Ubuntu 14.04 x86_64
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2016-11-07 12:08 UTC] hetao at hetao dot name
Description:
------------
When the passowrd is string("") and set ATTR_PERSISTENT is true, the PDO __construct where Fatal Error (You keep press the F5 in the browser , U will see the error some times)
If password is not empty or is null , it's ok.

$dsn = 'mysql:dbname=test;host=localhost;port=3306';
$user = 'root'; 
$password = "";//will wrong
//$password = null; //will ok     
                
try {
    $dbh = new PDO($dsn, $user, $password,
        array( 
            \PDO::ATTR_PERSISTENT => true
        )   
    );  
} catch (PDOException $e) {
    echo 'Connection failed: ' . $e->getMessage();
}   

Test script:
---------------
<?php           
/* Connect to an ODBC database using driver invocation */
$dsn = 'mysql:dbname=test;host=localhost;port=3306';
$user = 'root'; 
$password = "";
                
$dbh = new PDO($dsn, $user, $password,
    array(
        \PDO::ATTR_PERSISTENT => true
    )   
);  
print_r($dbh);


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-11-07 14:23 UTC] cmb@php.net
-Package: MySQL related +Package: PDO MySQL
 [2016-11-08 16:25 UTC] adambaratz@php.net
-Package: PDO MySQL +Package: PDO Core
 [2016-11-08 16:25 UTC] adambaratz@php.net
Changing package from PDO MySQL to PDO Code, since there are examples for multiple drivers.
 [2016-11-11 08:21 UTC] hetao at hetao dot name
-PHP Version: 5.6.27 +PHP Version: PHP Version 5.6.27-1+deb.sury.org~xenial+1
 [2016-11-11 08:21 UTC] hetao at hetao dot name
I compile the lastest php7,php5 src from the php.net, and the bug not exits.
May be the  PHP Version 5.6.27-1+deb.sury.org~xenial+1 problem?
 [2017-10-24 08:31 UTC] kalle@php.net
-Package: PDO Core +Package: PDO related
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Aug 20 22:01:30 2019 UTC