diff --git a/NEWS b/NEWS
index 7cbd644c50a..7bd388c1bfe 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,7 @@ PHP NEWS
- Fixed bug #49236 (Missing PHP_SUBST(PDO_MYSQL_SHARED_LIBADD)). (Jani)
- Fixed bug #49144 (Import of schema from different host transmits original
authentication details). (Dmitry)
+- Fixed bug #47273 (Encoding bug in SoapServer->fault). (Dmitry)
- Fixed bug #28038 (Sent incorrect RCPT TO commands to SMTP server) (Garrett)
diff --git a/ext/soap/soap.c b/ext/soap/soap.c
index ca2b0668fed..fc5b287067b 100644
--- a/ext/soap/soap.c
+++ b/ext/soap/soap.c
@@ -1956,8 +1956,13 @@ PHP_METHOD(SoapServer, fault)
char *code, *string, *actor=NULL, *name=NULL;
int code_len, string_len, actor_len, name_len;
zval* details = NULL;
+ soapServicePtr service;
+ xmlCharEncodingHandlerPtr old_encoding;
SOAP_SERVER_BEGIN_CODE();
+ FETCH_THIS_SERVICE(service);
+ old_encoding = SOAP_GLOBAL(encoding);
+ SOAP_GLOBAL(encoding) = service->encoding;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|szs",
&code, &code_len, &string, &string_len, &actor, &actor_len, &details,
@@ -1966,6 +1971,8 @@ PHP_METHOD(SoapServer, fault)
}
soap_server_fault(code, string, actor, details, name TSRMLS_CC);
+
+ SOAP_GLOBAL(encoding) = old_encoding;
SOAP_SERVER_END_CODE();
}
/* }}} */
diff --git a/ext/soap/tests/bugs/bug47273.phpt b/ext/soap/tests/bugs/bug47273.phpt
new file mode 100644
index 00000000000..174948f59f9
--- /dev/null
+++ b/ext/soap/tests/bugs/bug47273.phpt
@@ -0,0 +1,53 @@
+--TEST--
+Bug #47273 (Encoding bug in SoapServer->fault)
+--SKIPIF--
+
+--INI--
+unicode.script_encoding=ISO-8859-1
+unicode.output_encoding=ISO-8859-1
+--FILE--
+
+
+EOF;
+$request2 = <<
+
+EOF;
+
+class SoapFaultTest
+{
+ public function test1() {
+ // Test #1
+ return 'Test #1 exception with some special chars: Äßö';
+ }
+ public function test2() {
+ // Test #2
+ //throw new SoapFault('Server', 'Test #2 exception with some special chars: Äßö');
+ throw new Exception('Test #2 exception with some special chars: Äßö');
+ }
+}
+
+$server = new SoapServer(null, array(
+'uri' => "http://127.0.0.1:8080/test/",
+'encoding' => 'ISO-8859-1'));
+$server->setClass('SoapFaultTest');
+
+try {
+ $server->handle($request1);
+} catch (Exception $e) {
+ $server->fault("Sender", $e->getMessage());
+}
+try {
+ $server->handle($request2);
+} catch (Exception $e) {
+ $server->fault("Sender", $e->getMessage());
+}
+?>
+--EXPECT--
+
+Test #1 exception with some special chars: ÃÃö
+
+SenderTest #2 exception with some special chars: ÃÃö
+