summaryrefslogtreecommitdiff
path: root/Zend/zend.c
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2021-02-11 12:31:36 +0100
committerNikita Popov <nikita.ppv@gmail.com>2021-02-11 12:36:35 +0100
commit4c088c5da7fb96380a4cfc420d272075b40b6141 (patch)
tree41eb01867b511449353f5aeb4b006cbe98df37c7 /Zend/zend.c
parent4224b704b1e0262659262529e57ef97790712e42 (diff)
downloadphp-git-4c088c5da7fb96380a4cfc420d272075b40b6141.tar.gz
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.
Diffstat (limited to 'Zend/zend.c')
-rw-r--r--Zend/zend.c10
1 files changed, 9 insertions, 1 deletions
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;