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

Merge branch 'PHP-8.4'

* PHP-8.4:
  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:52 +02:00
3 changed files with 28 additions and 0 deletions

View File

@@ -1520,6 +1520,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

@@ -487,6 +487,9 @@ ZEND_API zval *zend_get_constant_ex(zend_string *cname, zend_class_entry *scope,
CONST_PROTECT_RECURSION(c);
zend_deprecated_constant(c, c->name);
CONST_UNPROTECT_RECURSION(c);
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