xref: /PHP-7.4/ext/mysqli/tests/bug33491.phpt (revision 782352c5)
1--TEST--
2Bug #33491 (extended mysqli class crashes when result is not object)
3--INI--
4error_reporting=1
5--SKIPIF--
6<?php
7require_once('skipif.inc');
8require_once('skipifconnectfailure.inc');
9?>
10--FILE--
11<?php
12
13class DB extends mysqli
14{
15  public function query_single($query) {
16    $result = parent::query($query);
17    $result->fetch_row(); // <- Here be crash
18  }
19}
20
21require_once("connect.inc");
22
23// Segfault when using the DB class which extends mysqli
24$DB = new DB($host, $user, $passwd, $db, $port, $socket);
25$DB->query_single('SELECT DATE()');
26
27?>
28--EXPECTF--
29Fatal error: Uncaught Error: Call to a member function fetch_row() on bool in %sbug33491.php:%d
30Stack trace:
31#0 %s(%d): DB->query_single('SELECT DATE()')
32#1 {main}
33  thrown in %sbug33491.php on line %d
34