Skip to content

Minor improvements in SOAP __doRequest dispatch #18687

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions ext/soap/soap.c
Original file line number Diff line number Diff line change
Expand Up @@ -2209,7 +2209,6 @@ static bool do_request(zval *this_ptr, xmlDoc *request, const char *location, co
bool ret = true;
char *buf;
int buf_size;
zval func;
zval params[5];
bool _bailout = false;

Expand All @@ -2222,13 +2221,6 @@ static bool do_request(zval *this_ptr, xmlDoc *request, const char *location, co
}

zend_try {
zval *trace = Z_CLIENT_TRACE_P(this_ptr);
if (Z_TYPE_P(trace) == IS_TRUE) {
zval_ptr_dtor(Z_CLIENT_LAST_REQUEST_P(this_ptr));
ZVAL_STRINGL(Z_CLIENT_LAST_REQUEST_P(this_ptr), buf, buf_size);
}

ZVAL_STRINGL(&func,"__doRequest",sizeof("__doRequest")-1);
ZVAL_STRINGL(&params[0], buf, buf_size);
ZVAL_STRING(&params[1], location);
if (action == NULL) {
Expand All @@ -2239,10 +2231,18 @@ static bool do_request(zval *this_ptr, xmlDoc *request, const char *location, co
ZVAL_LONG(&params[3], version);
ZVAL_BOOL(&params[4], one_way);

if (call_user_function(NULL, this_ptr, &func, response, 5, params) != SUCCESS) {
add_soap_fault(this_ptr, "Client", "SoapClient::__doRequest() failed", NULL, NULL);
ret = false;
} else if (Z_TYPE_P(response) != IS_STRING) {
zval *trace = Z_CLIENT_TRACE_P(this_ptr);
if (Z_TYPE_P(trace) == IS_TRUE) {
zval_ptr_dtor(Z_CLIENT_LAST_REQUEST_P(this_ptr));
ZVAL_COPY(Z_CLIENT_LAST_REQUEST_P(this_ptr), &params[0]);
}

zend_function *func = zend_hash_str_find_ptr(&Z_OBJCE_P(this_ptr)->function_table, ZEND_STRL("__dorequest"));
ZEND_ASSERT(func != NULL);

zend_call_known_instance_method(func, Z_OBJ_P(this_ptr), response, 5, params);

if (Z_TYPE_P(response) != IS_STRING) {
if (EG(exception) && instanceof_function(EG(exception)->ce, zend_ce_error)) {
/* Programmer error in __doRequest() implementation, let it bubble up. */
} else if (Z_TYPE_P(Z_CLIENT_SOAP_FAULT_P(this_ptr)) != IS_OBJECT) {
Expand All @@ -2256,7 +2256,6 @@ static bool do_request(zval *this_ptr, xmlDoc *request, const char *location, co
} zend_catch {
_bailout = true;
} zend_end_try();
zval_ptr_dtor(&func);
zval_ptr_dtor(&params[2]);
zval_ptr_dtor(&params[1]);
zval_ptr_dtor(&params[0]);
Expand Down