From f7bf9e6b5f9b082286150b8b6be9d069f9f40edc Mon Sep 17 00:00:00 2001 From: gggeek Date: Wed, 22 Feb 2023 12:20:44 +0000 Subject: [PATCH] fix legacy autoloading; add tests for it --- NEWS.md | 2 ++ demo/server/legacy.php | 18 ++++++++++++++++++ lib/xmlrpc.inc | 9 +++++---- tests/13LegacyAPITest.php | 20 ++++++++++++++++++++ tests/legacy_loader_test.php | 27 +++++++++++++++++++++++++++ 5 files changed, 72 insertions(+), 4 deletions(-) create mode 100644 demo/server/legacy.php create mode 100644 tests/13LegacyAPITest.php create mode 100644 tests/legacy_loader_test.php diff --git a/NEWS.md b/NEWS.md index 83180cda..c482c648 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ ## XML-RPC for PHP version 4.10.1 - unreleased +* fixed: class autoloading got broken in rel 4.10.0 for users of the legacy API (issue #111) + * fixed: let the Server create Response objects whose class can be overridden by subclasses (this is required by the json-rpc server now that the `xml_header` method has been moved to the `Request` object) diff --git a/demo/server/legacy.php b/demo/server/legacy.php new file mode 100644 index 00000000..52f5b608 --- /dev/null +++ b/demo/server/legacy.php @@ -0,0 +1,18 @@ +setDebug(3); +$s->service(); diff --git a/lib/xmlrpc.inc b/lib/xmlrpc.inc index b558c5e2..f15d82dc 100644 --- a/lib/xmlrpc.inc +++ b/lib/xmlrpc.inc @@ -62,16 +62,17 @@ include_once(__DIR__.'/../src/Exception/StateErrorException.php'); include_once(__DIR__.'/../src/Exception/TypeErrorException.php'); include_once(__DIR__.'/../src/Exception/ValueErrorException.php'); include_once(__DIR__.'/../src/PhpXmlRpc.php'); +include_once(__DIR__.'/../src/Traits/CharsetEncoderAware.php'); +include_once(__DIR__.'/../src/Traits/LoggerAware.php'); +include_once(__DIR__.'/../src/Traits/DeprecationLogger.php'); +include_once(__DIR__.'/../src/Traits/ParserAware.php'); +include_once(__DIR__.'/../src/Traits/PayloadBearer.php'); include_once(__DIR__.'/../src/Helper/Charset.php'); include_once(__DIR__.'/../src/Helper/Date.php'); include_once(__DIR__.'/../src/Helper/Http.php'); include_once(__DIR__.'/../src/Helper/Interop.php'); include_once(__DIR__.'/../src/Helper/Logger.php'); include_once(__DIR__.'/../src/Helper/XMLParser.php'); -include_once(__DIR__.'/../src/Traits/CharsetEncoderAware.php'); -include_once(__DIR__.'/../src/Traits/LoggerAware.php'); -include_once(__DIR__.'/../src/Traits/DeprecationLogger.php'); -include_once(__DIR__.'/../src/Traits/ParserAware.php'); include_once(__DIR__.'/../src/Value.php'); include_once(__DIR__.'/../src/Request.php'); include_once(__DIR__.'/../src/Response.php'); diff --git a/tests/13LegacyAPITest.php b/tests/13LegacyAPITest.php new file mode 100644 index 00000000..4c5c6367 --- /dev/null +++ b/tests/13LegacyAPITest.php @@ -0,0 +1,20 @@ +assertEquals(0, $result); + } +} diff --git a/tests/legacy_loader_test.php b/tests/legacy_loader_test.php new file mode 100644 index 00000000..3a0773ff --- /dev/null +++ b/tests/legacy_loader_test.php @@ -0,0 +1,27 @@ +setCookie('PHPUNIT_RANDOM_TEST_ID', $randId); + +$req = new xmlrpcmsg('system.listMethods', array()); +$resp = $client->send($req); +if ($resp->faultCode() !== 0) { + throw new \Exception("system.listMethods returned fault " . $resp->faultCode()); +} + +unlink(sys_get_temp_dir() . '/phpunit_rand_id.txt'); -- 2.47.0