1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

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
This commit is contained in:
Niels Dossche
2025-09-06 00:01:13 +02:00
4 changed files with 30 additions and 0 deletions

2
NEWS
View File

@@ -12,6 +12,8 @@ PHP NEWS
. Fixed bug GH-19613 (Stale array iterator pointer). (ilutov)
. Fixed bug GH-19679 (zend_ssa_range_widening may fail to converge). (Arnaud)
. Fixed bug GH-19681 (PHP_EXPAND_PATH broken with bash 5.3.0). (Remi)
. Fixed bug GH-19720 (Assertion failure when error handler throws when
accessing a deprecated constant). (nielsdos)
- CLI:
. Fixed bug GH-19461 (Improve error message on listening error with IPv6

View File

@@ -1512,6 +1512,9 @@ ZEND_API zend_result zend_update_class_constant(zend_class_constant *c, const ze
zval_ptr_dtor(&c->value);
ZVAL_COPY_VALUE(&c->value, &tmp);
/* may not return SUCCESS in case of an exception,
* should've returned FAILURE in zval_update_constant_ex! */
ZEND_ASSERT(!EG(exception));
return SUCCESS;
}

View File

@@ -464,6 +464,9 @@ ZEND_API zval *zend_get_constant_ex(zend_string *cname, zend_class_entry *scope,
if (!(flags & ZEND_FETCH_CLASS_SILENT) && (ZEND_CONSTANT_FLAGS(c) & CONST_DEPRECATED)) {
zend_error(E_DEPRECATED, "Constant %s is deprecated", name);
if (UNEXPECTED(EG(exception))) {
return NULL;
}
}
return &c->value;
}

View File

@@ -0,0 +1,22 @@
--TEST--
GH-19720 (Assertion failure when error handler throws when accessing a deprecated constant)
--EXTENSIONS--
zend_test
--FILE--
<?php
class Test {
public const MyConst = [ZEND_TEST_DEPRECATED => 42];
}
set_error_handler(function ($_, $errstr) {
throw new Exception($errstr);
});
try {
var_dump(Test::MyConst);
} catch (Exception $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECT--
Constant ZEND_TEST_DEPRECATED is deprecated