php-src/ext/mysqli/tests/mysqli_incomplete_initialization.phpt
Niels Dossche 2b6c9b68bb
Fix GH-17900 and GH-8084
Calling the constructor twice has no real world benefit.
Block it to fix these two issues.
We also clean up the constructor code a bit:
- `in_ctor` implies `object` exist.
- We surround the instance check with ZEND_DEBUG to avoid a runtime
  penalty.

Closes GH-17900.
Closes GH-8084.
Closes GH-17908.
2025-02-24 19:25:08 +01:00

19 lines
405 B
PHP

--TEST--
Incomplete initialization edge case where mysql->mysql is NULL
--EXTENSIONS--
mysqli
--FILE--
<?php
mysqli_report(MYSQLI_REPORT_OFF);
$mysqli = new mysqli();
@$mysqli->__construct('doesnotexist');
$mysqli->close();
?>
--EXPECTF--
Fatal error: Uncaught Error: Cannot call constructor twice in %s:%d
Stack trace:
#0 %s(%d): mysqli->__construct('doesnotexist')
#1 {main}
thrown in %s on line %d