xref: /PHP-8.2/ext/mysqli/tests/bug36802.phpt (revision b5a14e6c)
1--TEST--
2Bug #36802 (crashes with with mysqli_set_charset())
3--EXTENSIONS--
4mysqli
5--FILE--
6<?php
7    class really_my_mysqli extends mysqli {
8        function __construct()
9        {
10        }
11    }
12
13    require_once("connect.inc");
14    $mysql = mysqli_init();
15
16    /* following operations should not work */
17    if (method_exists($mysql, 'set_charset')) {
18        try {
19            $mysql->set_charset('utf8');
20        } catch (Error $exception) {
21            echo $exception->getMessage() . "\n";
22        }
23    } else {
24        $x[0] = false;
25    }
26
27    try {
28        $mysql->query("SELECT 'foo' FROM DUAL");
29    } catch (Error $exception) {
30        echo $exception->getMessage() . "\n";
31    }
32
33    /* following operations should work */
34    $x[1] = ($mysql->error);
35    $x[2] = $mysql->errno;
36
37    $mysql->close();
38
39    var_dump($x);
40?>
41--EXPECT--
42mysqli object is not fully initialized
43mysqli object is not fully initialized
44array(2) {
45  [1]=>
46  string(0) ""
47  [2]=>
48  int(0)
49}
50