Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 40edd58

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: standard: Take `zend.assertions` into account for dynamic calls to `assert()` (php#18521)
2 parents 84f82d0 + 8d2682f commit 40edd58

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

‎NEWS‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ PHP NEWS
3737
- Standard:
3838
. Fixed bug GH-17403 (Potential deadlock when putenv fails). (nielsdos)
3939
. Fixed bug GH-18400 (http_build_query type error is inaccurate). (nielsdos)
40+
. Fixed bug GH-18509 (Dynamic calls to assert() ignore zend.assertions).
41+
(timwolla)
4042

4143
- Windows:
4244
. Fix leak+crash with sapi_windows_set_ctrl_handler(). (nielsdos)

‎ext/standard/assert.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,11 @@ PHP_FUNCTION(assert)
178178
zend_string *description_str = NULL;
179179
zend_object *description_obj = NULL;
180180

181-
if (!ASSERTG(active)) {
181+
/* EG(assertions) <= 0 is only reachable by dynamic calls to assert(),
182+
* since calls known at compile time will skip the entire call when
183+
* assertions are disabled.
184+
*/
185+
if (!ASSERTG(active) || EG(assertions) <= 0) {
182186
RETURN_TRUE;
183187
}
184188

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
GH-18509: Dynamic calls to assert() ignore zend.assertions
3+
--INI--
4+
zend.assertions=0
5+
--FILE--
6+
<?php
7+
8+
$c = "assert";
9+
10+
$c(false);
11+
12+
var_dump(array_map(assert(...), [true, true, false]));
13+
14+
?>
15+
--EXPECT--
16+
array(3) {
17+
[0]=>
18+
bool(true)
19+
[1]=>
20+
bool(true)
21+
[2]=>
22+
bool(true)
23+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /