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: 2017-01-11 07:02 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: gpkappos at ucy dot ac dot cy Assigned:
Status: Open Package: PDO OCI
PHP Version: 5.6.29 OS: Windows 10
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or 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

Add a Patch

Pull Requests

Add a Pull Request

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);

?>
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Jul 24 06:01:27 2019 UTC