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 c583124

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Fix GH-19720: Assertion failure when error handler throws when accessing a deprecated constant
2 parents 1b49d0e + 9d69ab9 commit c583124

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

‎NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ PHP NEWS
1212
. Fixed bug GH-19613 (Stale array iterator pointer). (ilutov)
1313
. Fixed bug GH-19679 (zend_ssa_range_widening may fail to converge). (Arnaud)
1414
. Fixed bug GH-19681 (PHP_EXPAND_PATH broken with bash 5.3.0). (Remi)
15+
. Fixed bug GH-19720 (Assertion failure when error handler throws when
16+
accessing a deprecated constant). (nielsdos)
1517

1618
- CLI:
1719
. Fixed bug GH-19461 (Improve error message on listening error with IPv6

‎Zend/zend_API.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,6 +1512,9 @@ ZEND_API zend_result zend_update_class_constant(zend_class_constant *c, const ze
15121512
zval_ptr_dtor(&c->value);
15131513
ZVAL_COPY_VALUE(&c->value, &tmp);
15141514

1515+
/* may not return SUCCESS in case of an exception,
1516+
* should've returned FAILURE in zval_update_constant_ex! */
1517+
ZEND_ASSERT(!EG(exception));
15151518
return SUCCESS;
15161519
}
15171520

‎Zend/zend_constants.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,9 @@ ZEND_API zval *zend_get_constant_ex(zend_string *cname, zend_class_entry *scope,
464464

465465
if (!(flags & ZEND_FETCH_CLASS_SILENT) && (ZEND_CONSTANT_FLAGS(c) & CONST_DEPRECATED)) {
466466
zend_error(E_DEPRECATED, "Constant %s is deprecated", name);
467+
if (UNEXPECTED(EG(exception))) {
468+
return NULL;
469+
}
467470
}
468471
return &c->value;
469472
}

‎ext/zend_test/tests/gh19720.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
GH-19720 (Assertion failure when error handler throws when accessing a deprecated constant)
3+
--EXTENSIONS--
4+
zend_test
5+
--FILE--
6+
<?php
7+
class Test {
8+
public const MyConst = [ZEND_TEST_DEPRECATED => 42];
9+
}
10+
11+
set_error_handler(function ($_, $errstr) {
12+
throw new Exception($errstr);
13+
});
14+
15+
try {
16+
var_dump(Test::MyConst);
17+
} catch (Exception $e) {
18+
echo $e->getMessage(), "\n";
19+
}
20+
?>
21+
--EXPECT--
22+
Constant ZEND_TEST_DEPRECATED is deprecated

0 commit comments

Comments
(0)

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