Skip to content

Commit c26ba69

Browse files
committed
build: replace the bundled xmlrpc library with phpxmlrpc 4
1 parent 39a169e commit c26ba69

8 files changed

Lines changed: 88 additions & 5249 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- Add correlated structured logging to all MailScanner REST requests
1212

1313
### Changed
14+
- Replace the bundled `phpxmlrpc` 3.0.0.beta with the maintained `phpxmlrpc/phpxmlrpc` 4.x from Composer; node-to-node RPC keeps the same wire format, and the deprecation notices the bundled copy emitted on PHP 8.2 and later are gone
1415
- Move the three REST APIs from legacy `mysqli` access to Doctrine DBAL without changing their versioned contracts
1516
- Rename terminology from "whitelist/blacklist" to "allowlist/blocklist" throughout the application (database tables, columns, Perl modules, UI) (#1186)
1617
- Standardised database charset to utf8mb4 with unicode_520_ci collation
@@ -22,6 +23,7 @@
2223

2324
### Compatibility
2425
- The minimal PHP version is now 8.3.
26+
- `ext-xml` is now a declared requirement rather than a suggestion; it was already mandatory at runtime
2527
- The minimal supported MySQL version is now 5.7.42
2628
- The minimal supported MariaDB version is now 10.4.34
2729

composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
"php": "8.3.* || 8.4.* || 8.5.*",
88
"ext-mysqli": "*",
99
"ext-pdo_mysql": "*",
10+
"ext-xml": "*",
1011
"doctrine/dbal": "^4.4",
1112
"doctrine/migrations": "^3.9",
13+
"phpxmlrpc/phpxmlrpc": "^4",
1214
"psr/log": "^3",
1315
"symfony/mailer": "^6|^7|^8",
1416
"symfony/process": "^6|^7|^8",
@@ -32,8 +34,8 @@
3234
},
3335
"suggest": {
3436
"ext-ldap": "For LDAP support",
35-
"ext-xml": "For XMLRPC support",
36-
"ext-imap": "For IMAP support"
37+
"ext-imap": "For IMAP support",
38+
"ext-curl": "For node-to-node RPC over HTTPS"
3739
},
3840
"autoload": {
3941
"psr-4": {

composer.lock

Lines changed: 64 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mailscanner/functions.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@
113113
// Set PHP path to use local PEAR modules only
114114
set_include_path(
115115
'.' . PATH_SEPARATOR .
116-
MAILWATCH_HOME . '/lib/pear' . PATH_SEPARATOR .
117-
MAILWATCH_HOME . '/lib/xmlrpc'
116+
MAILWATCH_HOME . '/lib/pear'
118117
);
119118

120119
// ForceUTF8
@@ -150,9 +149,14 @@
150149
if (!function_exists('xml_parser_create') && (!ini_get('enable_dl') || true !== @dl('xml.so'))) {
151150
exit(__('phpxmlnotloaded03'));
152151
}
153-
require_once __DIR__ . '/lib/xmlrpc/xmlrpc.inc';
154-
require_once __DIR__ . '/lib/xmlrpc/xmlrpcs.inc';
155-
require_once __DIR__ . '/lib/xmlrpc/xmlrpc_wrappers.inc';
152+
// The compatibility layer of phpxmlrpc 4, which declares the same global
153+
// names the pages and rpcserver.php have always used. Upstream marks it
154+
// deprecated: it is here so that a maintained library replaces the vendored
155+
// 3.0.0.beta without touching a line of protocol code, and it goes when the
156+
// REST replacement of section 12 does.
157+
require_once \dirname(__DIR__) . '/vendor/phpxmlrpc/phpxmlrpc/lib/xmlrpc.inc';
158+
require_once \dirname(__DIR__) . '/vendor/phpxmlrpc/phpxmlrpc/lib/xmlrpcs.inc';
159+
require_once \dirname(__DIR__) . '/vendor/phpxmlrpc/phpxmlrpc/lib/xmlrpc_wrappers.inc';
156160

157161
include __DIR__ . '/postfix.inc.php';
158162
include __DIR__ . '/msmail.inc.php';
@@ -3809,7 +3813,7 @@ function is_rpc_client_allowed()
38093813
}
38103814

38113815
/**
3812-
* @return xmlrpcresp
3816+
* @return \PhpXmlRpc\Response
38133817
*/
38143818
function xmlrpc_wrapper($host, $msg)
38153819
{
@@ -3834,7 +3838,11 @@ function xmlrpc_wrapper($host, $msg)
38343838
$client->setSSLVerifyPeer(false);
38353839
$client->setSSLVerifyHost(0);
38363840

3837-
return $client->send($msg, 0, $method);
3841+
$response = $client->send($msg, 0, $method);
3842+
3843+
// The client answers with an array only when it is given several requests
3844+
// at once, which no caller here does.
3845+
return \is_array($response) ? reset($response) : $response;
38383846
}
38393847

38403848
/**

0 commit comments

Comments
 (0)