Skip to content

Commit c8e3e52

Browse files
committed
Factor out
1 parent 4b085c5 commit c8e3e52

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

ext/soap/soap.c

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,12 @@ static void type_to_string(sdlTypePtr type, smart_str *buf, int level);
5050

5151
static void clear_soap_fault(zval *obj);
5252
static void set_soap_fault(zval *obj, const char *fault_code_ns, const char *fault_code, const char *fault_string, const char *fault_actor, zval *fault_detail, zend_string *name, zend_string *lang);
53+
static void add_soap_fault_en(zval *obj, char *fault_code, char *fault_string, char *fault_actor, zval *fault_detail);
5354
static void add_soap_fault_ex(zval *fault, zval *obj, char *fault_code, char *fault_string, char *fault_actor, zval *fault_detail, zend_string *lang);
55+
static void add_soap_fault_ex_en(zval *fault, zval *obj, char *fault_code, char *fault_string, char *fault_actor, zval *fault_detail);
5456
static ZEND_NORETURN void soap_server_fault(char* code, char* string, char *actor, zval* details, zend_string *name, zend_string *lang);
55-
static ZEND_NORETURN void soap_server_fault_en(char* code, char* string, char *actor, zval* details, zend_string *name);
5657
static void soap_server_fault_ex(sdlFunctionPtr function, zval* fault, soapHeader* hdr);
58+
static ZEND_NORETURN void soap_server_fault_en(char* code, char* string, char *actor, zval* details, zend_string *name);
5759

5860
static sdlParamPtr get_param(sdlFunctionPtr function, const char *param_name, zend_ulong index, int);
5961
static sdlFunctionPtr get_function(sdlPtr sdl, const char *function_name, size_t function_name_length);
@@ -1254,10 +1256,10 @@ static void _soap_server_exception(soapServicePtr service, sdlFunctionPtr functi
12541256
if (service->send_errors) {
12551257
zval rv;
12561258
zend_string *msg = zval_get_string(zend_read_property_ex(zend_ce_error, Z_OBJ(exception_object), ZSTR_KNOWN(ZEND_STR_MESSAGE), /* silent */ false, &rv));
1257-
add_soap_fault_ex(&exception_object, this_ptr, "Server", ZSTR_VAL(msg), NULL, NULL, SOAP_GLOBAL(lang_en));
1259+
add_soap_fault_ex_en(&exception_object, this_ptr, "Server", ZSTR_VAL(msg), NULL, NULL);
12581260
zend_string_release_ex(msg, 0);
12591261
} else {
1260-
add_soap_fault_ex(&exception_object, this_ptr, "Server", "Internal Error", NULL, NULL, SOAP_GLOBAL(lang_en));
1262+
add_soap_fault_ex_en(&exception_object, this_ptr, "Server", "Internal Error", NULL, NULL);
12611263
}
12621264
soap_server_fault_ex(function, &exception_object, NULL);
12631265
}
@@ -1876,7 +1878,7 @@ static zend_never_inline ZEND_COLD void soap_real_error_handler(int error_num, z
18761878
code = "Client";
18771879
}
18781880

1879-
add_soap_fault_ex(&fault, &SOAP_GLOBAL(error_object), code, ZSTR_VAL(message), NULL, NULL, SOAP_GLOBAL(lang_en));
1881+
add_soap_fault_ex_en(&fault, &SOAP_GLOBAL(error_object), code, ZSTR_VAL(message), NULL, NULL);
18801882
Z_ADDREF(fault);
18811883
zend_throw_exception_object(&fault);
18821884
zend_bailout();
@@ -2230,7 +2232,7 @@ static bool do_request(zval *this_ptr, xmlDoc *request, const char *location, co
22302232

22312233
xmlDocDumpMemory(request, (xmlChar**)&buf, &buf_size);
22322234
if (!buf) {
2233-
add_soap_fault(this_ptr, "HTTP", "Error build soap request", NULL, NULL, SOAP_GLOBAL(lang_en));
2235+
add_soap_fault_en(this_ptr, "HTTP", "Error build soap request", NULL, NULL);
22342236
return false;
22352237
}
22362238

@@ -2260,7 +2262,7 @@ static bool do_request(zval *this_ptr, xmlDoc *request, const char *location, co
22602262
if (EG(exception) && instanceof_function(EG(exception)->ce, zend_ce_error)) {
22612263
/* Programmer error in __doRequest() implementation, let it bubble up. */
22622264
} else if (Z_TYPE_P(Z_CLIENT_SOAP_FAULT_P(this_ptr)) != IS_OBJECT) {
2263-
add_soap_fault(this_ptr, "Client", "SoapClient::__doRequest() returned non string value", NULL, NULL, SOAP_GLOBAL(lang_en));
2265+
add_soap_fault_en(this_ptr, "Client", "SoapClient::__doRequest() returned non string value", NULL, NULL);
22642266
}
22652267
ret = false;
22662268
} else if (Z_TYPE_P(trace) == IS_TRUE) {
@@ -2420,15 +2422,15 @@ static void do_soap_call(zend_execute_data *execute_data,
24202422
smart_str_append(&error,function);
24212423
smart_str_appends(&error,"\") is not a valid method for this service");
24222424
smart_str_0(&error);
2423-
add_soap_fault(this_ptr, "Client", ZSTR_VAL(error.s), NULL, NULL, SOAP_GLOBAL(lang_en));
2425+
add_soap_fault_en(this_ptr, "Client", ZSTR_VAL(error.s), NULL, NULL);
24242426
smart_str_free(&error);
24252427
}
24262428
} else {
24272429
zval *uri = Z_CLIENT_URI_P(this_ptr);
24282430
if (Z_TYPE_P(uri) != IS_STRING) {
2429-
add_soap_fault(this_ptr, "Client", "Error finding \"uri\" property", NULL, NULL, SOAP_GLOBAL(lang_en));
2431+
add_soap_fault_en(this_ptr, "Client", "Error finding \"uri\" property", NULL, NULL);
24302432
} else if (location == NULL) {
2431-
add_soap_fault(this_ptr, "Client", "Error could not find \"location\" property", NULL, NULL, SOAP_GLOBAL(lang_en));
2433+
add_soap_fault_en(this_ptr, "Client", "Error could not find \"location\" property", NULL, NULL);
24322434
} else {
24332435
if (call_uri == NULL) {
24342436
call_uri = Z_STR_P(uri);
@@ -2465,7 +2467,7 @@ static void do_soap_call(zend_execute_data *execute_data,
24652467
if (Z_TYPE_P(fault) == IS_OBJECT) {
24662468
ZVAL_COPY(return_value, fault);
24672469
} else {
2468-
add_soap_fault_ex(return_value, this_ptr, "Client", "Unknown Error", NULL, NULL, SOAP_GLOBAL(lang_en));
2470+
add_soap_fault_ex_en(return_value, this_ptr, "Client", "Unknown Error", NULL, NULL);
24692471
Z_ADDREF_P(return_value);
24702472
}
24712473
} else {
@@ -2930,13 +2932,23 @@ static void add_soap_fault_ex(zval *fault, zval *obj, char *fault_code, char *fa
29302932
}
29312933
/* }}} */
29322934

2935+
static void add_soap_fault_ex_en(zval *fault, zval *obj, char *fault_code, char *fault_string, char *fault_actor, zval *fault_detail)
2936+
{
2937+
add_soap_fault_ex(fault, obj, fault_code, fault_string, fault_actor, fault_detail, SOAP_GLOBAL(lang_en));
2938+
}
2939+
29332940
void add_soap_fault(zval *obj, char *fault_code, char *fault_string, char *fault_actor, zval *fault_detail, zend_string *lang) /* {{{ */
29342941
{
29352942
zval fault;
29362943
add_soap_fault_ex(&fault, obj, fault_code, fault_string, fault_actor, fault_detail, lang);
29372944
}
29382945
/* }}} */
29392946

2947+
static void add_soap_fault_en(zval *obj, char *fault_code, char *fault_string, char *fault_actor, zval *fault_detail)
2948+
{
2949+
add_soap_fault(obj, fault_code, fault_string, fault_actor, fault_detail, SOAP_GLOBAL(lang_en));
2950+
}
2951+
29402952
static void set_soap_fault(zval *obj, const char *fault_code_ns, const char *fault_code, const char *fault_string, const char *fault_actor, zval *fault_detail, zend_string *name, zend_string *lang) /* {{{ */
29412953
{
29422954
if (Z_TYPE_P(obj) != IS_OBJECT) {

0 commit comments

Comments
 (0)