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