xref: /PHP-8.2/ext/mysqli/tests/bug36949.phpt (revision b5a14e6c)
1--TEST--
2Bug #36949 (invalid internal mysqli objects dtor)
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once('skipifconnectfailure.inc');
8?>
9--FILE--
10<?php
11require_once("connect.inc");
12class A {
13
14    private $mysqli;
15
16    public function __construct() {
17        global $user, $host, $passwd, $db, $port, $socket;
18        $this->mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket);
19        $result = $this->mysqli->query("SELECT NOW() AS my_time FROM DUAL");
20        $row = $result->fetch_object();
21        echo $row->my_time."<br>\n";
22        $result->close();
23    }
24
25    public function __destruct() {
26        $this->mysqli->close();
27    }
28}
29
30class B {
31
32    private $mysqli;
33
34    public function __construct() {
35        global $user, $host, $passwd, $db, $port, $socket;
36        $this->mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket);
37        $result = $this->mysqli->query("SELECT NOW() AS my_time FROM DUAL");
38        $row = $result->fetch_object();
39        echo $row->my_time."<br>\n";
40        $result->close();
41    }
42
43    public function __destruct() {
44        $this->mysqli->close();
45    }
46}
47
48$A = new A();
49$B = new B();
50?>
51--CLEAN--
52<?php
53require_once("connect.inc");
54if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
55   printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
56
57if (!mysqli_query($link, "DROP TABLE IF EXISTS my_time"))
58    printf("[002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
59
60mysqli_close($link);
61?>
62--EXPECTF--
63%d%d%d%d-%d%d-%d%d %d%d:%d%d:%d%d<br>
64%d%d%d%d-%d%d-%d%d %d%d:%d%d:%d%d<br>
65