Merge branch 'PHP-8.3' into PHP-8.4

* PHP-8.3:
  standard: Take `zend.assertions` into account for dynamic calls to `assert()` (#18521)
This commit is contained in:
Tim Düsterhus 2025-05-12 08:44:57 +02:00
commit 40edd58d36
No known key found for this signature in database
3 changed files with 30 additions and 1 deletions

2
NEWS
View file

@ -37,6 +37,8 @@ PHP NEWS
- Standard:
. Fixed bug GH-17403 (Potential deadlock when putenv fails). (nielsdos)
. Fixed bug GH-18400 (http_build_query type error is inaccurate). (nielsdos)
. Fixed bug GH-18509 (Dynamic calls to assert() ignore zend.assertions).
(timwolla)
- Windows:
. Fix leak+crash with sapi_windows_set_ctrl_handler(). (nielsdos)

View file

@ -178,7 +178,11 @@ PHP_FUNCTION(assert)
zend_string *description_str = NULL;
zend_object *description_obj = NULL;
if (!ASSERTG(active)) {
/* EG(assertions) <= 0 is only reachable by dynamic calls to assert(),
* since calls known at compile time will skip the entire call when
* assertions are disabled.
*/
if (!ASSERTG(active) || EG(assertions) <= 0) {
RETURN_TRUE;
}

View file

@ -0,0 +1,23 @@
--TEST--
GH-18509: Dynamic calls to assert() ignore zend.assertions
--INI--
zend.assertions=0
--FILE--
<?php
$c = "assert";
$c(false);
var_dump(array_map(assert(...), [true, true, false]));
?>
--EXPECT--
array(3) {
[0]=>
bool(true)
[1]=>
bool(true)
[2]=>
bool(true)
}