php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73865 extending PDO conflict with persistent connections
Submitted: 2017-01-05 06:22 UTC Modified: 2021-03-03 15:41 UTC
Votes:4
Avg. Score:1.5 ± 0.9
Reproduced:0 of 0 (0.0%)
From: gpkappos at ucy dot ac dot cy Assigned: cmb (profile)
Status: Closed Package: PDO Core
PHP Version: 5.6.29 OS: Windows 10
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: gpkappos at ucy dot ac dot cy
New email:
PHP Version: OS:

 

 [2017-01-05 06:22 UTC] gpkappos at ucy dot ac dot cy
Description:
------------
When extending PDO, if you use persistent connections you can only create instances of the first object that uses the connection.
In the example below the constructor for B returns an instance of A


Test script:
---------------
class A extends \PDO {
    public function __construct()
    {
        parent::__construct('oci:dbname=//dbserver.example.org:1521/dbserver.example.org;charset=AL32UTF8', 'test', 'testpw', [PDO::ATTR_PERSISTENT => true]);
    }
}

class B extends \PDO {
    public function __construct()
    {
        parent::__construct('oci:dbname=//dbserver.example.org:1521/dbserver.example.org;charset=AL32UTF8', 'test', 'testpw', [PDO::ATTR_PERSISTENT => true]);
    }
}


$a = new A();

var_dump($a);

$b = new B();

var_dump($b);

Expected result:
----------------
object(A)[1]
object(B)[2]

Actual result:
--------------
object(A)[1]
object(A)[2]

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-11 04:57 UTC] krakjoe@php.net
-Status: Open +Status: Feedback
 [2017-01-11 04:57 UTC] krakjoe@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.


 [2017-01-11 07:02 UTC] gpkappos at ucy dot ac dot cy
-Status: Feedback +Status: Open
 [2017-01-11 07:02 UTC] gpkappos at ucy dot ac dot cy
Hello, thank you for your reply.
Here is the script, it uses oracle instant client and an oracle database but no tables are needed, just a connection:

<?php

class A extends \PDO {
    public function __construct()
    {
        parent::__construct('oci:dbname=//<dbserver1>:1521/<servicename1>;charset=AL32UTF8', 'scott', 'tiger', [PDO::ATTR_PERSISTENT => true]);
    }
}

class B extends \PDO {
    public function __construct()
    {
        parent::__construct('oci:dbname=//<dbserver1>:1521/<servicename1>;charset=AL32UTF8', 'scott', 'tiger', [PDO::ATTR_PERSISTENT => true]);
    }
}

$a = new A();
var_dump($a);
$b = new B();
var_dump($b);

?>
 [2021-03-03 12:24 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-03-03 12:24 UTC] cmb@php.net
I have no OCI setup to test this, but I don't think it's driver
specific behavior, and for PDO_MYSQL, PDO_SQLITE and PDO_ODBC I
get the expected result.  Or can you still reproduce this with any
of the actively supported PHP versions[1]?

[1] <https://www.php.net/supported-versions.php>
 [2021-03-03 14:20 UTC] gpkappos at ucy dot ac dot cy
-Status: Feedback +Status: Assigned
 [2021-03-03 14:20 UTC] gpkappos at ucy dot ac dot cy
No I cannot reproduce in newer verions
 [2021-03-03 15:41 UTC] cmb@php.net
-Status: Assigned +Status: Closed -Package: PDO OCI +Package: PDO Core
 [2021-03-03 15:41 UTC] cmb@php.net
Thanks for the swift reply!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 14 10:01:28 2024 UTC