Skip to content

Commit e144fc6

Browse files
committed
Factor out
1 parent 0bea07d commit e144fc6

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);
@@ -1253,10 +1255,10 @@ static void _soap_server_exception(soapServicePtr service, sdlFunctionPtr functi
12531255
if (service->send_errors) {
12541256
zval rv;
12551257
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));
1256-
add_soap_fault_ex(&exception_object, this_ptr, "Server", ZSTR_VAL(msg), NULL, NULL, SOAP_GLOBAL(lang_en));
1258+
add_soap_fault_ex_en(&exception_object, this_ptr, "Server", ZSTR_VAL(msg), NULL, NULL);
12571259
zend_string_release_ex(msg, 0);
12581260
} else {
1259-
add_soap_fault_ex(&exception_object, this_ptr, "Server", "Internal Error", NULL, NULL, SOAP_GLOBAL(lang_en));
1261+
add_soap_fault_ex_en(&exception_object, this_ptr, "Server", "Internal Error", NULL, NULL);
12601262
}
12611263
soap_server_fault_ex(function, &exception_object, NULL);
12621264
}
@@ -1875,7 +1877,7 @@ static zend_never_inline ZEND_COLD void soap_real_error_handler(int error_num, z
18751877
code = "Client";
18761878
}
18771879

1878-
add_soap_fault_ex(&fault, &SOAP_GLOBAL(error_object), code, ZSTR_VAL(message), NULL, NULL, SOAP_GLOBAL(lang_en));
1880+
add_soap_fault_ex_en(&fault, &SOAP_GLOBAL(error_object), code, ZSTR_VAL(message), NULL, NULL);
18791881
Z_ADDREF(fault);
18801882
zend_throw_exception_object(&fault);
18811883
zend_bailout();
@@ -2229,7 +2231,7 @@ static bool do_request(zval *this_ptr, xmlDoc *request, const char *location, co
22292231

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

@@ -2259,7 +2261,7 @@ static bool do_request(zval *this_ptr, xmlDoc *request, const char *location, co
22592261
if (EG(exception) && instanceof_function(EG(exception)->ce, zend_ce_error)) {
22602262
/* Programmer error in __doRequest() implementation, let it bubble up. */
22612263
} else if (Z_TYPE_P(Z_CLIENT_SOAP_FAULT_P(this_ptr)) != IS_OBJECT) {
2262-
add_soap_fault(this_ptr, "Client", "SoapClient::__doRequest() returned non string value", NULL, NULL, SOAP_GLOBAL(lang_en));
2264+
add_soap_fault_en(this_ptr, "Client", "SoapClient::__doRequest() returned non string value", NULL, NULL);
22632265
}
22642266
ret = false;
22652267
} else if (Z_TYPE_P(trace) == IS_TRUE) {
@@ -2419,15 +2421,15 @@ static void do_soap_call(zend_execute_data *execute_data,
24192421
smart_str_append(&error,function);
24202422
smart_str_appends(&error,"\") is not a valid method for this service");
24212423
smart_str_0(&error);
2422-
add_soap_fault(this_ptr, "Client", ZSTR_VAL(error.s), NULL, NULL, SOAP_GLOBAL(lang_en));
2424+
add_soap_fault_en(this_ptr, "Client", ZSTR_VAL(error.s), NULL, NULL);
24232425
smart_str_free(&error);
24242426
}
24252427
} else {
24262428
zval *uri = Z_CLIENT_URI_P(this_ptr);
24272429
if (Z_TYPE_P(uri) != IS_STRING) {
2428-
add_soap_fault(this_ptr, "Client", "Error finding \"uri\" property", NULL, NULL, SOAP_GLOBAL(lang_en));
2430+
add_soap_fault_en(this_ptr, "Client", "Error finding \"uri\" property", NULL, NULL);
24292431
} else if (location == NULL) {
2430-
add_soap_fault(this_ptr, "Client", "Error could not find \"location\" property", NULL, NULL, SOAP_GLOBAL(lang_en));
2432+
add_soap_fault_en(this_ptr, "Client", "Error could not find \"location\" property", NULL, NULL);
24312433
} else {
24322434
if (call_uri == NULL) {
24332435
call_uri = Z_STR_P(uri);
@@ -2464,7 +2466,7 @@ static void do_soap_call(zend_execute_data *execute_data,
24642466
if (Z_TYPE_P(fault) == IS_OBJECT) {
24652467
ZVAL_COPY(return_value, fault);
24662468
} else {
2467-
add_soap_fault_ex(return_value, this_ptr, "Client", "Unknown Error", NULL, NULL, SOAP_GLOBAL(lang_en));
2469+
add_soap_fault_ex_en(return_value, this_ptr, "Client", "Unknown Error", NULL, NULL);
24682470
Z_ADDREF_P(return_value);
24692471
}
24702472
} else {
@@ -2929,13 +2931,23 @@ static void add_soap_fault_ex(zval *fault, zval *obj, char *fault_code, char *fa
29292931
}
29302932
/* }}} */
29312933

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

2946+
static void add_soap_fault_en(zval *obj, char *fault_code, char *fault_string, char *fault_actor, zval *fault_detail)
2947+
{
2948+
add_soap_fault(obj, fault_code, fault_string, fault_actor, fault_detail, SOAP_GLOBAL(lang_en));
2949+
}
2950+
29392951
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) /* {{{ */
29402952
{
29412953
if (Z_TYPE_P(obj) != IS_OBJECT) {

0 commit comments

Comments
 (0)