From 4c088c5da7fb96380a4cfc420d272075b40b6141 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 11 Feb 2021 12:31:36 +0100 Subject: Handle warnings during sccp function evaluation Some upcoming changes like https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg will make it somewhat inconvenient to determine whether a given function invocation will generate a diagnostic. Rather than trying to exclude this in advance, call the function with diagnostics suppressed, and check whether anything was thrown. This adds a new EG flag that is kept specific to the SCCP use-case. This does not use the error_cb hook as it is a (non-TLS) global, and doesn't fully suppress error handling besides. Test this by removing the in advance checks for implode and array_flip. --- Zend/zend.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'Zend/zend.c') diff --git a/Zend/zend.c b/Zend/zend.c index 4518322622..f8bca2cd6b 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -714,7 +714,7 @@ static void executor_globals_ctor(zend_executor_globals *executor_globals) /* {{ zend_init_exception_op(); zend_init_call_trampoline_op(); memset(&executor_globals->trampoline, 0, sizeof(zend_op_array)); - executor_globals->lambda_count = 0; + executor_globals->warnings_during_sccp = 0; ZVAL_UNDEF(&executor_globals->user_error_handler); ZVAL_UNDEF(&executor_globals->user_exception_handler); executor_globals->in_autoload = NULL; @@ -1299,6 +1299,14 @@ static ZEND_COLD void zend_error_impl( zend_stack delayed_oplines_stack; int type = orig_type & E_ALL; + /* If we're executing a function during SCCP, count any warnings that may be emitted, + * but don't perform any other error handling. */ + if (EG(capture_warnings_during_sccp)) { + ZEND_ASSERT(!(type & E_FATAL_ERRORS) && "Fatal error during SCCP"); + EG(capture_warnings_during_sccp)++; + return; + } + /* Report about uncaught exception in case of fatal errors */ if (EG(exception)) { zend_execute_data *ex; -- cgit v1.2.1