From 3ab75c7a03a662924d85da9bdcba170b99995cdb Mon Sep 17 00:00:00 2001 From: Alliballibaba Date: Fri, 30 Oct 2026 17:13:49 +0100 Subject: [PATCH 1/3] unsets the error handler while parsing the request briefly. --- frankenphp.c | 8 +++++++ testdata/error-handler.php | 17 +++++++++++++ testdata/request-parse-errors.php | 23 ++++++++++++++++++ worker_test.go | 40 +++++++++++++++++++++++++++++++ 4 files changed, 88 insertions(+) create mode 100644 testdata/error-handler.php create mode 100644 testdata/request-parse-errors.php diff --git a/frankenphp.c b/frankenphp.c index 4066845349..22825a5e41 100644 --- a/frankenphp.c +++ b/frankenphp.c @@ -685,6 +685,11 @@ void get_full_env(zval *track_vars_array) { static int frankenphp_worker_request_startup() { int retval = SUCCESS; + /* Use the default error handler while parsing the worker request */ + zval orig_user_error_handler; + ZVAL_COPY_VALUE(&orig_user_error_handler, &EG(user_error_handler)); + ZVAL_UNDEF(&EG(user_error_handler)); + frankenphp_update_request_context(); zend_try { @@ -747,6 +752,9 @@ static int frankenphp_worker_request_startup() { zend_catch { retval = FAILURE; } zend_end_try(); + /* Restore the original user error handler */ + ZVAL_COPY_VALUE(&EG(user_error_handler), &orig_user_error_handler); + SG(sapi_started) = 1; return retval; diff --git a/testdata/error-handler.php b/testdata/error-handler.php new file mode 100644 index 0000000000..bd3cc2ba38 --- /dev/null +++ b/testdata/error-handler.php @@ -0,0 +1,17 @@ + Date: Fri, 30 Oct 2026 17:45:12 +0100 Subject: [PATCH 2/3] fixes error handler for low PHP versions --- testdata/error-handler.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/testdata/error-handler.php b/testdata/error-handler.php index bd3cc2ba38..f65205fd7d 100644 --- a/testdata/error-handler.php +++ b/testdata/error-handler.php @@ -12,6 +12,11 @@ ++$requests; echo "requests:$requests\n"; - $handler = get_error_handler(); - echo $handler ? "handler is defined" : "handler is not defined"; + // get_error_handler is not available in PHP <= 8.4 + if (function_exists('get_error_handler')) { + $handler = get_error_handler(); + echo $handler ? "handler is defined" : "handler is not defined"; + } else { + echo "handler is defined"; + } }; \ No newline at end of file From d4a035775e396fb3965461d9da713fc78389ce3e Mon Sep 17 00:00:00 2001 From: Alliballibaba Date: Fri, 30 Oct 2026 17:50:08 +0100 Subject: [PATCH 3/3] linting --- testdata/error-handler.php | 2 +- testdata/request-parse-errors.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/testdata/error-handler.php b/testdata/error-handler.php index f65205fd7d..08403ad225 100644 --- a/testdata/error-handler.php +++ b/testdata/error-handler.php @@ -19,4 +19,4 @@ } else { echo "handler is defined"; } -}; \ No newline at end of file +}; diff --git a/testdata/request-parse-errors.php b/testdata/request-parse-errors.php index 43eed569c3..c6cc499be7 100644 --- a/testdata/request-parse-errors.php +++ b/testdata/request-parse-errors.php @@ -20,4 +20,4 @@ ++$requests; echo "requests:{$requests}\n"; -}; \ No newline at end of file +};