From be7f4844d627b6063b94ba4cf2c0b90232515819 Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Mon, 9 Dec 2024 05:17:12 +0900 Subject: [PATCH] Improve error handling in interceptor execution Add explicit error handling when interceptor call fails but doesn't raise an exception. The change separates error conditions between call failure and exceptions, providing more detailed error reporting through php_rayaop_handle_error. - Split call_user_function result check into separate variable - Add specific error handling for call failures - Report errors with RAYAOP_E_INVALID_HANDLER code Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- rayaop.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rayaop.c b/rayaop.c index 620fba5..a37944a 100644 --- a/rayaop.c +++ b/rayaop.c @@ -234,7 +234,8 @@ static void rayaop_execute_ex(zend_execute_data *execute_data) { ZVAL_STRING(&method_name, "intercept"); RAYAOP_G(is_intercepting) = 1; - if (call_user_function(NULL, &info->handler, &method_name, &retval, 3, params) == SUCCESS && !EG(exception)) { + int call_result = call_user_function(NULL, &info->handler, &method_name, &retval, 3, params); + if (call_result == SUCCESS && !EG(exception)) { if (execute_data->return_value) { if (!Z_ISUNDEF(retval)) { ZVAL_COPY(execute_data->return_value, &retval); // Propagate explicit return values @@ -242,6 +243,8 @@ static void rayaop_execute_ex(zend_execute_data *execute_data) { ZVAL_NULL(execute_data->return_value); // Handle void or empty returns } } + } else if (call_result != SUCCESS) { + php_rayaop_handle_error(RAYAOP_E_INVALID_HANDLER, "Interceptor call failed"); } cleanup: