xref: /PHP-8.1/ext/pdo_mysql/tests/bug63176.phpt (revision b5a14e6c)
1--TEST--
2Bug #63176 (Segmentation fault when instantiate 2 persistent PDO to the same db server)
3--EXTENSIONS--
4pdo_mysql
5--SKIPIF--
6<?php
7require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
8MySQLPDOTest::skip();
9?>
10--FILE--
11<?php
12require(__DIR__. DIRECTORY_SEPARATOR . 'config.inc');
13class PDO2 extends PDO {
14    protected $transLevel;
15}
16
17class PDO3 extends PDO {
18    protected $tomato;
19}
20
21
22class ModelA {
23    public function __construct($h) {
24        var_dump($h);
25        if ($h) {
26            $this->db = new PDO2(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_USER, PDO_MYSQL_TEST_PASS, array(PDO::ATTR_PERSISTENT => true));
27        } else {
28            $this->db = new PDO3(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_USER, PDO_MYSQL_TEST_PASS, array(PDO::ATTR_PERSISTENT => true));
29        }
30        $this->db->query('SELECT 1')->fetchAll();
31    }
32}
33
34$a = new ModelA(true);
35$b = new ModelA(false);
36
37var_dump($a);
38var_dump($b);
39?>
40--EXPECTF--
41bool(true)
42bool(false)
43object(ModelA)#%d (1) {
44  ["db"]=>
45  object(PDO2)#%d (1) {
46    ["transLevel":protected]=>
47    NULL
48  }
49}
50object(ModelA)#%d (1) {
51  ["db"]=>
52  object(PDO3)#%d (1) {
53    ["tomato":protected]=>
54    NULL
55  }
56}
57