From 158a4d5dfa57445cb580e52486d815cbabc96d2a Mon Sep 17 00:00:00 2001 From: gggeek <giunta.gaetano@gmail.com> Date: Thu, 2 Feb 2023 08:29:02 +0000 Subject: [PATCH] more deprecations; docs --- NEWS.md | 2 ++ src/Client.php | 1 + src/Request.php | 5 ++++- src/Response.php | 3 +++ src/Server.php | 1 + tests/08ServerTest.php | 2 +- 6 files changed, 12 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index 2c45e041..60f1cfae 100644 --- a/NEWS.md +++ b/NEWS.md @@ -65,6 +65,8 @@ * fixed: setting values to deprecated Response property `cookies` would trigger a PHP notice, ex: `$response->_cookies['name'] = ['value' => 'something'];` (introduced in 4.6.0) +* fixed: made deprecated method `Value::structEach` work again with php 8.0 and later + * new: method `PhpXmlRpc::useInteropFaults()` can be used to make the library change the error codes it generates to match the spec described at https://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php diff --git a/src/Client.php b/src/Client.php index 49822222..d10938b1 100644 --- a/src/Client.php +++ b/src/Client.php @@ -1079,6 +1079,7 @@ class Client // Only create the payload if it was not created previously /// @todo what if the request's payload was created with a different encoding? + /// Also, if we do not call serialize(), the request will not set its content-type to have the charset declared if (empty($req->payload)) { $req->serialize($opts['request_charset_encoding']); } diff --git a/src/Request.php b/src/Request.php index b2910655..7f177b0a 100644 --- a/src/Request.php +++ b/src/Request.php @@ -74,18 +74,21 @@ class Request } /** - * @internal this function will become protected in the future + * @internal this function will become protected in the future (and be folded into serialize) * * @param string $charsetEncoding * @return void */ public function createPayload($charsetEncoding = '') { + $this->logDeprecationUnlessCalledBy('serialize'); + if ($charsetEncoding != '') { $this->content_type = 'text/xml; charset=' . $charsetEncoding; } else { $this->content_type = 'text/xml'; } + $this->payload = $this->xml_header($charsetEncoding); $this->payload .= '<methodName>' . $this->getCharsetEncoder()->encodeEntities( $this->methodname, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "</methodName>\n"; diff --git a/src/Response.php b/src/Response.php index 2147179b..2665e995 100644 --- a/src/Response.php +++ b/src/Response.php @@ -32,6 +32,7 @@ class Response public $payload; /** @var string */ public $content_type = 'text/xml'; + protected $httpResponse = array('headers' => array(), 'cookies' => array(), 'raw_data' => '', 'status_code' => null); /** @@ -156,6 +157,7 @@ class Response } else { $this->content_type = 'text/xml'; } + if (PhpXmlRpc::$xmlrpc_null_apache_encoding) { $result = "<methodResponse xmlns:ex=\"" . PhpXmlRpc::$xmlrpc_null_apache_encoding_ns . "\">\n"; } else { @@ -184,6 +186,7 @@ class Response } } $result .= "\n</methodResponse>"; + $this->payload = $result; return $result; diff --git a/src/Server.php b/src/Server.php index cbbb1e13..16c6253b 100644 --- a/src/Server.php +++ b/src/Server.php @@ -406,6 +406,7 @@ class Server // Do not create response serialization if it has already happened. Helps to build json magic /// @todo what if the payload was created targeting a different charset than $respCharset? + /// Also, if we do not call serialize(), the request will not set its content-type to have the charset declared if (empty($resp->payload)) { $resp->serialize($respCharset); } diff --git a/tests/08ServerTest.php b/tests/08ServerTest.php index 6f9f9765..69068e70 100644 --- a/tests/08ServerTest.php +++ b/tests/08ServerTest.php @@ -1006,7 +1006,7 @@ And turned it into nylon'; $this->assertEquals('200', $h['status_code']); $this->assertNotEmpty($h['headers']); - $d = $this->client->debug; + $d = $this->client->getOption('debug'); $this->client->setDebug(-1); $v2 = $this->send($m, 0, true); $this->client->setDebug($d); -- 2.47.0