Convert exception during inheritance to fatal error

Now that inheritance can throw deprecations again, these may be
converted to exception by a custom error handler. In this case
we need to convert the exception to a fatal error, as inheritance
cannot safely throw in the general case.
This commit is contained in:
Nikita Popov 2021-05-28 10:19:23 +02:00
parent 6e477d205e
commit 100a1e8e21
5 changed files with 43 additions and 16 deletions

View file

@ -968,6 +968,22 @@ ZEND_API ZEND_COLD zend_result zend_exception_error(zend_object *ex, int severit
}
/* }}} */
ZEND_NORETURN void zend_exception_uncaught_error(const char *format, ...) {
va_list va;
va_start(va, format);
zend_string *prefix = zend_vstrpprintf(0, format, va);
va_end(va);
ZEND_ASSERT(EG(exception));
zval exception_zv;
ZVAL_OBJ_COPY(&exception_zv, EG(exception));
zend_clear_exception();
zend_string *exception_str = zval_get_string(&exception_zv);
zend_error_noreturn(E_ERROR,
"%s: Uncaught %s", ZSTR_VAL(prefix), ZSTR_VAL(exception_str));
}
ZEND_API ZEND_COLD void zend_throw_exception_object(zval *exception) /* {{{ */
{
if (exception == NULL || Z_TYPE_P(exception) != IS_OBJECT) {