xref: /php-src/ext/pdo_mysql/tests/bug63176.phpt (revision 4bb75d56)
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__ . '/inc/mysql_pdo_test.inc';
8MySQLPDOTest::skip();
9?>
10--FILE--
11<?php
12require_once __DIR__ . '/inc/mysql_pdo_test.inc';
13
14class PDO2 extends PDO {
15    protected $transLevel;
16}
17
18class PDO3 extends PDO {
19    protected $tomato;
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, [PDO::ATTR_PERSISTENT => true]);
28        } else {
29            $this->db = new PDO3(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_USER, PDO_MYSQL_TEST_PASS, [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