xref: /PHP-8.4/ext/pdo_sqlite/tests/bug43831.phpt (revision 74859783)
1--TEST--
2Bug #43831 ($this gets mangled when extending PDO with persistent connection)
3--EXTENSIONS--
4pdo_sqlite
5--FILE--
6<?php
7
8class Foo extends PDO {
9    function __construct($dsn) {
10        parent::__construct($dsn, null, null, array(PDO::ATTR_PERSISTENT => true));
11    }
12}
13
14class Baz extends PDO {
15    function __construct($dsn) {
16        parent::__construct($dsn, null, null, array(PDO::ATTR_PERSISTENT => true));
17    }
18}
19
20class Bar extends Baz {
21    function quux() {
22        echo get_class($this), "\n";
23        $foo = new Foo("sqlite::memory:");
24        echo get_class($this), "\n";
25    }
26}
27
28$bar = new Bar("sqlite::memory:");
29$bar->quux();
30
31
32class MyPDO extends PDO {}
33
34$bar = new PDO("sqlite::memory:", null, null, array(PDO::ATTR_PERSISTENT => true));
35$baz = new MyPDO("sqlite::memory:", null, null, array(PDO::ATTR_PERSISTENT => true));
36
37var_dump($bar);
38unset($bar);
39var_dump($baz);
40var_dump($bar);
41
42
43?>
44--EXPECTF--
45Bar
46Bar
47object(PDO)#%d (0) {
48}
49object(MyPDO)#%d (0) {
50}
51
52Warning: Undefined variable $bar in %s on line %d
53NULL
54