diff --git a/ext/soap/soap.c b/ext/soap/soap.c index 48a7fc8885e44..ef00324d8afef 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -1307,19 +1307,17 @@ PHP_METHOD(SoapServer, handle) sapi_add_header(hdr, sizeof("Location: ")+strlen(service->sdl->source)-1, 1); efree(hdr); */ - zval readfile, readfile_ret, param; sapi_add_header("Content-Type: text/xml; charset=utf-8", sizeof("Content-Type: text/xml; charset=utf-8")-1, 1); - ZVAL_STRING(¶m, service->sdl->source); - ZVAL_STRING(&readfile, "readfile"); - if (call_user_function(EG(function_table), NULL, &readfile, &readfile_ret, 1, ¶m ) == FAILURE) { + php_stream_context *context = php_stream_context_from_zval(NULL, false); + php_stream *stream = php_stream_open_wrapper_ex(service->sdl->source, "rb", REPORT_ERRORS, NULL, context); + if (stream) { + php_stream_passthru(stream); + php_stream_close(stream); + } else { soap_server_fault("Server", "Couldn't find WSDL", NULL, NULL, NULL); } - zval_ptr_dtor(¶m); - zval_ptr_dtor_str(&readfile); - zval_ptr_dtor(&readfile_ret); - SOAP_SERVER_END_CODE(); return; } else { diff --git a/ext/soap/tests/SoapServer/handle_non_existing_WSDL_from_get_query.phpt b/ext/soap/tests/SoapServer/handle_non_existing_WSDL_from_get_query.phpt new file mode 100644 index 0000000000000..ca9f9f06ae93c --- /dev/null +++ b/ext/soap/tests/SoapServer/handle_non_existing_WSDL_from_get_query.phpt @@ -0,0 +1,86 @@ +--TEST-- +SoapServer handle with WSDL that has disappeared +--EXTENSIONS-- +soap +--SKIPIF-- + +--GET-- +WSDL +--FILE-- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +WSDL; + +file_put_contents($wsdlFile, $wsdl); + +$options = []; +$server = new SoapServer($wsdlFile, $options); + +unlink($wsdlFile); + +$server->handle(); + +?> +--CLEAN-- + +--EXPECT-- + +SOAP-ENV:ServerCouldn't find WSDL diff --git a/ext/soap/tests/SoapServer/handle_non_existing_WSDL_from_get_query_disable_readfile.phpt b/ext/soap/tests/SoapServer/handle_non_existing_WSDL_from_get_query_disable_readfile.phpt new file mode 100644 index 0000000000000..183a00acab238 --- /dev/null +++ b/ext/soap/tests/SoapServer/handle_non_existing_WSDL_from_get_query_disable_readfile.phpt @@ -0,0 +1,87 @@ +--TEST-- +SoapServer handle with WSDL that has disappeared and disabled readfile function +--EXTENSIONS-- +soap +--SKIPIF-- + +--GET-- +WSDL +--INI-- +disable_functions=readfile +--FILE-- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +WSDL; + +file_put_contents($wsdlFile, $wsdl); + +$options = []; +$server = new SoapServer($wsdlFile, $options); + +unlink($wsdlFile); +$server->handle(); + +?> +--CLEAN-- + +--EXPECT-- + +SOAP-ENV:ServerCouldn't find WSDL