xref: /PHP-8.2/ext/pdo_mysql/tests/bug63176.phpt (revision 902d6439)
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 $db;
24    public function __construct($h) {
25        var_dump($h);
26        if ($h) {
27            $this->db = new PDO2(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_USER, PDO_MYSQL_TEST_PASS, array(PDO::ATTR_PERSISTENT => true));
28        } else {
29            $this->db = new PDO3(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_USER, PDO_MYSQL_TEST_PASS, array(PDO::ATTR_PERSISTENT => true));
30        }
31        $this->db->query('SELECT 1')->fetchAll();
32    }
33}
34
35$a = new ModelA(true);
36$b = new ModelA(false);
37
38var_dump($a);
39var_dump($b);
40?>
41--EXPECTF--
42bool(true)
43bool(false)
44object(ModelA)#%d (1) {
45  ["db"]=>
46  object(PDO2)#%d (1) {
47    ["transLevel":protected]=>
48    NULL
49  }
50}
51object(ModelA)#%d (1) {
52  ["db"]=>
53  object(PDO3)#%d (1) {
54    ["tomato":protected]=>
55    NULL
56  }
57}
58