Merge branch 'MDL-81669_upgrade-phpxmlrpc' of https://github.com/ziegenberg/moodle
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,65 @@
|
||||
XMLRPC for PHP (a.k.a. PHPXMLRPC)
|
||||
=================================
|
||||
|
||||
A php library for building xml-rpc clients and servers.
|
||||
|
||||
Requirements and Installation
|
||||
-----------------------------
|
||||
|
||||
The recommended way to install this library is using Composer.
|
||||
|
||||
Detailed installation instructions are in the [INSTALL.md](INSTALL.md) file, along with system requirements listing.
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
|
||||
* See the documentation page at [gggeek.github.io/phpxmlrpc](https://gggeek.github.io/phpxmlrpc) for a list of the
|
||||
library main features and all project related information, including information about online resources such as
|
||||
debuggers and demo servers.
|
||||
|
||||
* The user manual can be found in the doc/manual directory: [phpxmlrpc_manual.adoc](doc/manual/phpxmlrpc_manual.adoc).
|
||||
It includes sections about upgrading from previous versions and the Backwards compatibility promise as well as about
|
||||
running the library's testing suite and bundled debugger.
|
||||
|
||||
The manual is formatted as an asciidoc file - if viewing it locally, it is recommended to either use an IDE which can
|
||||
natively render asciidoc, or view it as html with a browser by serving it via a webserver and accessing
|
||||
/doc/manual/index.html
|
||||
|
||||
The latest version of the manual is also accessible online at https://github.com/gggeek/phpxmlrpc/blob/master/doc/manual/phpxmlrpc_manual.adoc
|
||||
|
||||
* Automatically-generated documentation for the API is available online at [http://gggeek.github.io/phpxmlrpc/doc-4/api/index.html](http://gggeek.github.io/phpxmlrpc/doc-4/api/index.html)
|
||||
|
||||
* You are encouraged to look also at the code examples found in the demo/ directory.
|
||||
|
||||
Note: to reduce the size of the download, the demo files are not part of the default package installed with Composer.
|
||||
You can either check them out online at https://github.com/gggeek/phpxmlrpc/tree/master/demo, download them as a separate
|
||||
tarball from https://github.com/gggeek/phpxmlrpc/releases or make sure they are available locally by installing the
|
||||
library using Composer option `--prefer-install=source`. Whatever the method chosen, make sure that the demo folder is
|
||||
not directly accessible from the internet, i.e. it is not within the webserver root directory).
|
||||
|
||||
Extras
|
||||
------
|
||||
|
||||
* This library does include a visual debugger which can be used to troubleshoot connections to 3rd party xml-rpc servers.
|
||||
In case you'd like to use the debugger but do not have a working PHP installation, you can run it standalone as a
|
||||
Container image. Instructions can be found at https://github.com/gggeek/phpxmlrpc-debugger
|
||||
|
||||
* A companion PHP library, which adds support for the JSON-RPC protocol, is available at https://github.com/gggeek/phpxmlrpc-jsonrpc
|
||||
|
||||
* A companion PHP library, which adds support for XML-RPC servers to automatically generate API documentation, and more,
|
||||
is available at https://github.com/gggeek/phpxmlrpc-extras
|
||||
|
||||
* Lats but not least, a Javascript library, implementing both XML-RPC and JSON-RPC clients using a very similar API, is
|
||||
available at https://github.com/gggeek/jsxmlrpc
|
||||
|
||||
License
|
||||
-------
|
||||
Use of this software is subject to the terms in the [license.txt](license.txt) file
|
||||
|
||||
|
||||
[](https://packagist.org/packages/phpxmlrpc/phpxmlrpc)
|
||||
[](https://packagist.org/packages/phpxmlrpc/phpxmlrpc)
|
||||
[](https://packagist.org/packages/phpxmlrpc/phpxmlrpc)
|
||||
|
||||
[](https://github.com/gggeek/phpxmlrpc/actions/workflows/ci.yml)
|
||||
[](https://app.codecov.io/gh/gggeek/phpxmlrpc)
|
||||
@@ -0,0 +1,29 @@
|
||||
Software License Agreement (BSD License)
|
||||
|
||||
Copyright (c) 1999,2000,2001 Edd Dumbill, Useful Information Company
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of the "XML-RPC for PHP" nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -7,23 +7,15 @@ from PHP code. It's a modern replacement for the old
|
||||
(removed from core since PHP 8.0) xmlrpc extension.
|
||||
|
||||
To update:
|
||||
- Pick a release of the library @ https://github.com/gggeek/phpxmlrpc/releases.
|
||||
- Pick a release of the library @ https://github.com/gggeek/phpxmlrpc/releases.
|
||||
- Download or checkout it.
|
||||
- Delete the contents on the lib/phpxmlrpc directory (but this file) completely.
|
||||
- Copy the /src directory contents of the library to lib/phpxmlrpc.
|
||||
- Delete the contents of the lib/phpxmlrpc/src directory completely.
|
||||
- Copy the /src directory of the library to lib/phpxmlrpc/.
|
||||
- Remove the following files:
|
||||
- Autoloader.php
|
||||
- Edit this file and update the release and commit details below.
|
||||
- lib/phpxmlrpc/src/Autoloader.php
|
||||
- Copy the following files to lib/phpxmlrpc:
|
||||
- composer.json
|
||||
- license.txt
|
||||
- README.md
|
||||
- NEWS.md
|
||||
- Edit lib/thirdpartylibs.xml and update the information details too.
|
||||
|
||||
Current version imported: 4.10.1 (ac18e31)
|
||||
|
||||
Local changes:
|
||||
* 2023/01/26 - Server.php and Value.php files have minor changes for PHP 8.2 compatibility. See MDL-76415 for more details.
|
||||
Since version 4.9.1, the phpxmlrpc already has the fix, so if someone executing the upgrading version and
|
||||
it has the patch, please ignore this note.
|
||||
* 2023-01-31 lib/phpxmlrpc/* has minor changes for PHP 8.2 compatibility. See MDL-76412 for more details.
|
||||
Since version 4.9.5, phpxmlrpc already has the fix, so if someone executing the upgrading version and
|
||||
it has the patch, please ignore this note.
|
||||
* 2023-01-31 Applied patch https://github.com/gggeek/phpxmlrpc/pull/110. See MDL-76412 for more details.
|
||||
* readme_moodle.txt - this file ;-)
|
||||
|
||||
@@ -57,6 +57,7 @@ class Client
|
||||
const OPT_USE_CURL = 'use_curl';
|
||||
const OPT_VERIFY_HOST = 'verifyhost';
|
||||
const OPT_VERIFY_PEER = 'verifypeer';
|
||||
const OPT_EXTRA_HEADERS = 'extra_headers';
|
||||
|
||||
/** @var string */
|
||||
protected static $requestClass = '\\PhpXmlRpc\\Request';
|
||||
@@ -258,6 +259,13 @@ class Client
|
||||
*/
|
||||
protected $user_agent;
|
||||
|
||||
/**
|
||||
* Additional headers to be included in the requests.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $extra_headers = array();
|
||||
|
||||
/**
|
||||
* CURL handle: used for keep-alive
|
||||
* @internal
|
||||
@@ -299,6 +307,7 @@ class Client
|
||||
self::OPT_USERNAME,
|
||||
self::OPT_VERIFY_HOST,
|
||||
self::OPT_VERIFY_PEER,
|
||||
self::OPT_EXTRA_HEADERS,
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -669,7 +678,7 @@ class Client
|
||||
*
|
||||
* @todo check correctness of urlencoding cookie value (copied from php way of doing it, but php is generally sending
|
||||
* response not requests. We do the opposite...)
|
||||
* @todo strip invalid chars from cookie name? As per RFC6265, we should follow RFC2616, Section 2.2
|
||||
* @todo strip invalid chars from cookie name? As per RFC 6265, we should follow RFC 2616, Section 2.2
|
||||
* @todo drop/rename $port parameter. Cookies are not isolated by port!
|
||||
* @todo feature-creep allow storing 'expires', 'secure', 'httponly' and 'samesite' cookie attributes (we could do
|
||||
* as php, and allow $path to be an array of attributes...)
|
||||
@@ -822,6 +831,7 @@ class Client
|
||||
return $this->multicall($req, $timeout, $method);
|
||||
} elseif (is_string($req)) {
|
||||
$n = new static::$requestClass('');
|
||||
/// @todo we should somehow allow the caller to declare a custom contenttype too, esp. for the charset declaration
|
||||
$n->setPayload($req);
|
||||
$req = $n;
|
||||
}
|
||||
@@ -986,7 +996,7 @@ class Client
|
||||
$uri = $path;
|
||||
}
|
||||
|
||||
// Cookie generation, as per RFC6265
|
||||
// Cookie generation, as per RFC 6265
|
||||
// NB: the following code does not honour 'expires', 'path' and 'domain' cookie attributes set to client obj by the user...
|
||||
$cookieHeader = '';
|
||||
if (count($opts['cookies'])) {
|
||||
@@ -998,6 +1008,11 @@ class Client
|
||||
$cookieHeader = 'Cookie:' . $version . substr($cookieHeader, 0, -1) . "\r\n";
|
||||
}
|
||||
|
||||
$extraHeaders = '';
|
||||
if (is_array($this->extra_headers) && $this->extra_headers) {
|
||||
$extraHeaders = implode("\r\n", $this->extra_headers) . "\r\n";
|
||||
}
|
||||
|
||||
// omit port if default
|
||||
if (($port == 80 && in_array($method, array('http', 'http10'))) || ($port == 443 && $method == 'https')) {
|
||||
$port = '';
|
||||
@@ -1014,8 +1029,9 @@ class Client
|
||||
$encodingHdr .
|
||||
'Accept-Charset: ' . implode(',', $opts['accepted_charset_encodings']) . "\r\n" .
|
||||
$cookieHeader .
|
||||
'Content-Type: ' . $req->getContentType() . "\r\nContent-Length: " .
|
||||
strlen($payload) . "\r\n\r\n" .
|
||||
'Content-Type: ' . $req->getContentType() . "\r\n" .
|
||||
$extraHeaders .
|
||||
'Content-Length: ' . strlen($payload) . "\r\n\r\n" .
|
||||
$payload;
|
||||
|
||||
if ($opts['debug'] > 1) {
|
||||
@@ -1339,6 +1355,10 @@ class Client
|
||||
$headers[] = $encodingHdr;
|
||||
}
|
||||
|
||||
if (is_array($this->extra_headers) && $this->extra_headers) {
|
||||
$headers = array_merge($headers, $this->extra_headers);
|
||||
}
|
||||
|
||||
// Fix the HTTP/1.1 417 Expectation Failed Bug (curl by default adds a 'Expect: 100-continue' header when POST
|
||||
// size exceeds 1025 bytes, apparently)
|
||||
$headers[] = 'Expect:';
|
||||
|
||||
@@ -55,7 +55,6 @@ class Charset
|
||||
/**
|
||||
* @param string $tableName
|
||||
* @return void
|
||||
*
|
||||
* @throws ValueErrorException for unsupported $tableName
|
||||
*
|
||||
* @todo add support for cp1252 as well as latin-2 .. latin-10
|
||||
|
||||
@@ -11,7 +11,7 @@ class Http
|
||||
use LoggerAware;
|
||||
|
||||
/**
|
||||
* Decode a string that is encoded with "chunked" transfer encoding as defined in rfc2068 par. 19.4.6.
|
||||
* Decode a string that is encoded with "chunked" transfer encoding as defined in RFC 2068 par. 19.4.6.
|
||||
* Code shamelessly stolen from nusoap library by Dietrich Ayala.
|
||||
* @internal this function will become protected in the future
|
||||
*
|
||||
@@ -72,8 +72,8 @@ class Http
|
||||
* @return array with keys 'headers', 'cookies', 'raw_data' and 'status_code'
|
||||
* @throws HttpException
|
||||
*
|
||||
* @todo if $debug is < 0, we could avoid populating 'raw_data' and 'headers' in the returned value - but that would
|
||||
* be a weird API...
|
||||
* @todo if $debug is < 0, we could avoid populating 'raw_data' in the returned value - but that would
|
||||
* be a weird API... (note that we still need to always have headers parsed for content charset)
|
||||
*/
|
||||
public function parseResponseHeaders(&$data, $headersProcessed = false, $debug = 0)
|
||||
{
|
||||
|
||||
@@ -162,7 +162,7 @@ class XMLParser
|
||||
'isf_reason' => '',
|
||||
'value' => null,
|
||||
'method' => false, // so we can check later if we got a methodname or not
|
||||
'params' => array(),
|
||||
'params' => false, // so we can check later if we got a params tag or not
|
||||
'pt' => array(),
|
||||
'rt' => '',
|
||||
);
|
||||
@@ -237,34 +237,31 @@ class XMLParser
|
||||
// always set this, in case someone tries to disable it via options...
|
||||
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 1);
|
||||
|
||||
xml_set_object($parser, $this);
|
||||
|
||||
switch ($returnType) {
|
||||
case self::RETURN_PHP:
|
||||
xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee_fast');
|
||||
xml_set_element_handler($parser, array($this, 'xmlrpc_se'), array($this, 'xmlrpc_ee_fast'));
|
||||
break;
|
||||
case self::RETURN_EPIVALS:
|
||||
xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee_epi');
|
||||
xml_set_element_handler($parser, array($this, 'xmlrpc_se'), array($this, 'xmlrpc_ee_epi'));
|
||||
break;
|
||||
/// @todo log an error / throw / error-out on unsupported return type
|
||||
case XMLParser::RETURN_XMLRPCVALS:
|
||||
default:
|
||||
xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee');
|
||||
xml_set_element_handler($parser, array($this, 'xmlrpc_se'), array($this, 'xmlrpc_ee'));
|
||||
}
|
||||
|
||||
xml_set_character_data_handler($parser, 'xmlrpc_cd');
|
||||
xml_set_default_handler($parser, 'xmlrpc_dh');
|
||||
xml_set_character_data_handler($parser, array($this, 'xmlrpc_cd'));
|
||||
xml_set_default_handler($parser, array($this, 'xmlrpc_dh'));
|
||||
|
||||
try {
|
||||
// @see ticket #70 - we have to parse big xml docs in chunks to avoid errors
|
||||
for ($offset = 0; $offset < $len; $offset += $this->maxChunkLength) {
|
||||
$chunk = substr($data, $offset, $this->maxChunkLength);
|
||||
// error handling: xml not well formed
|
||||
if (!xml_parse($parser, $chunk, $offset + $this->maxChunkLength >= $len)) {
|
||||
if (!@xml_parse($parser, $chunk, $offset + $this->maxChunkLength >= $len)) {
|
||||
$errCode = xml_get_error_code($parser);
|
||||
$errStr = sprintf('XML error %s: %s at line %d, column %d', $errCode, xml_error_string($errCode),
|
||||
xml_get_current_line_number($parser), xml_get_current_column_number($parser));
|
||||
|
||||
$this->_xh['isf'] = 3;
|
||||
$this->_xh['isf_reason'] = $errStr;
|
||||
}
|
||||
@@ -290,6 +287,11 @@ class XMLParser
|
||||
xml_parser_free($parser);
|
||||
$this->current_parsing_options = array();
|
||||
|
||||
// BC
|
||||
if ($this->_xh['params'] === false) {
|
||||
$this->_xh['params'] = array();
|
||||
}
|
||||
|
||||
return $this->_xh;
|
||||
}
|
||||
|
||||
@@ -419,10 +421,13 @@ class XMLParser
|
||||
|
||||
case 'METHODCALL':
|
||||
case 'METHODRESPONSE':
|
||||
case 'PARAMS':
|
||||
// valid elements that add little to processing
|
||||
break;
|
||||
|
||||
case 'PARAMS':
|
||||
$this->_xh['params'] = array();
|
||||
break;
|
||||
|
||||
case 'METHODNAME':
|
||||
case 'NAME':
|
||||
/// @todo we could check for 2 NAME elements inside a MEMBER element
|
||||
@@ -751,13 +756,31 @@ class XMLParser
|
||||
break;
|
||||
|
||||
/// @todo add extra checking:
|
||||
/// - METHODRESPONSE should contain either a PARAMS with a single PARAM, or a FAULT
|
||||
/// - FAULT should contain a single struct with the 2 expected members (check their name and type)
|
||||
/// - METHODCALL should contain a methodname
|
||||
case 'PARAMS':
|
||||
case 'FAULT':
|
||||
break;
|
||||
|
||||
case 'METHODCALL':
|
||||
/// @todo should we allow to accept this case via a call to handleParsingError ?
|
||||
if ($this->_xh['method'] === false) {
|
||||
$this->_xh['isf'] = 2;
|
||||
$this->_xh['isf_reason'] = "missing METHODNAME element inside METHODCALL";
|
||||
}
|
||||
break;
|
||||
|
||||
case 'METHODRESPONSE':
|
||||
/// @todo should we allow to accept these cases via a call to handleParsingError ?
|
||||
if ($this->_xh['isf'] != 1 && $this->_xh['params'] === false) {
|
||||
$this->_xh['isf'] = 2;
|
||||
$this->_xh['isf_reason'] = "missing both FAULT and PARAMS elements inside METHODRESPONSE";
|
||||
} elseif ($this->_xh['isf'] == 0 && count($this->_xh['params']) !== 1) {
|
||||
$this->_xh['isf'] = 2;
|
||||
$this->_xh['isf_reason'] = "PARAMS element inside METHODRESPONSE should have exactly 1 PARAM";
|
||||
} elseif ($this->_xh['isf'] == 1 && $this->_xh['params'] !== false) {
|
||||
$this->_xh['isf'] = 2;
|
||||
$this->_xh['isf_reason'] = "both FAULT and PARAMS elements found inside METHODRESPONSE";
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -839,6 +862,7 @@ class XMLParser
|
||||
/**
|
||||
* xml charset encoding guessing helper function.
|
||||
* Tries to determine the charset encoding of an XML chunk received over HTTP.
|
||||
*
|
||||
* NB: according to the spec (RFC 3023), if text/xml content-type is received over HTTP without a content-type,
|
||||
* we SHOULD assume it is strictly US-ASCII. But we try to be more tolerant of non-conforming (legacy?) clients/servers,
|
||||
* which will be most probably using UTF-8 anyway...
|
||||
@@ -855,6 +879,8 @@ class XMLParser
|
||||
* @return string the encoding determined. Null if it can't be determined and mbstring is enabled,
|
||||
* PhpXmlRpc::$xmlrpc_defencoding if it can't be determined and mbstring is not enabled
|
||||
*
|
||||
* @todo as of 2023, the relevant RFC for XML Media Types is now 7303, and for HTTP it is 9110. Check if the order of
|
||||
* precedence implemented here is still correct
|
||||
* @todo explore usage of mb_http_input(): does it detect http headers + post data? if so, use it instead of hand-detection!!!
|
||||
* @todo feature-creep make it possible to pass in options overriding usage of PhpXmlRpc static variables, to make
|
||||
* the method independent of global state
|
||||
@@ -903,6 +929,7 @@ class XMLParser
|
||||
// Details:
|
||||
// SPACE: (#x20 | #x9 | #xD | #xA)+ === [ \x9\xD\xA]+
|
||||
// EQ: SPACE?=SPACE? === [ \x9\xD\xA]*=[ \x9\xD\xA]*
|
||||
// We could be stricter on version number: VersionNum ::= '1.' [0-9]+
|
||||
if (preg_match('/^<\?xml\s+version\s*=\s*' . "((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))" .
|
||||
'\s+encoding\s*=\s*' . "((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/",
|
||||
$xmlChunk, $matches)) {
|
||||
@@ -927,10 +954,13 @@ class XMLParser
|
||||
|
||||
return $enc;
|
||||
} else {
|
||||
// no encoding specified: as per HTTP1.1 assume it is iso-8859-1?
|
||||
// Both RFC 2616 (HTTP 1.1) and 1945 (HTTP 1.0) clearly state that for text/xxx content types
|
||||
// No encoding specified: assume it is iso-8859-1, as per HTTP1.1?
|
||||
// Both RFC 2616 (HTTP 1.1) and RFC 1945 (HTTP 1.0) clearly state that for text/xxx content types
|
||||
// this should be the standard. And we should be getting text/xml as request and response.
|
||||
// BUT we have to be backward compatible with the lib, which always used UTF-8 as default...
|
||||
// BUT we have to be backward compatible with the lib, which always used UTF-8 as default. Moreover,
|
||||
// RFC 7231, which obsoletes the two RFC mentioned above, has changed the rules. It says:
|
||||
// "The default charset of ISO-8859-1 for text media types has been removed; the default is now whatever
|
||||
// the media type definition says."
|
||||
return PhpXmlRpc::$xmlrpc_defencoding;
|
||||
}
|
||||
}
|
||||
@@ -959,6 +989,7 @@ class XMLParser
|
||||
// Details:
|
||||
// SPACE: (#x20 | #x9 | #xD | #xA)+ === [ \x9\xD\xA]+
|
||||
// EQ: SPACE?=SPACE? === [ \x9\xD\xA]*=[ \x9\xD\xA]*
|
||||
// We could be stricter on version number: VersionNum ::= '1.' [0-9]+
|
||||
if (preg_match('/^<\?xml\s+version\s*=\s*' . "((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))" .
|
||||
'\s+encoding\s*=\s*' . "((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/",
|
||||
$xmlChunk)) {
|
||||
|
||||
@@ -119,7 +119,7 @@ class PhpXmlRpc
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public static $xmlrpcVersion = "4.10.1";
|
||||
public static $xmlrpcVersion = "4.11.1";
|
||||
|
||||
/**
|
||||
* @var int
|
||||
|
||||
@@ -247,7 +247,7 @@ class Request
|
||||
} catch (HttpException $e) {
|
||||
// failed processing of HTTP response headers
|
||||
// save into response obj the full payload received, for debugging
|
||||
return new Response(0, $e->getCode(), $e->getMessage(), '', array('raw_data' => $data, 'status_code', $e->statusCode()));
|
||||
return new Response(0, $e->getCode(), $e->getMessage(), '', array('raw_data' => $data, 'status_code' => $e->statusCode()));
|
||||
} catch(\Exception $e) {
|
||||
return new Response(0, $e->getCode(), $e->getMessage(), '', array('raw_data' => $data));
|
||||
}
|
||||
@@ -356,8 +356,9 @@ class Request
|
||||
//}
|
||||
}
|
||||
// third error check: parsing of the response has somehow gone boink.
|
||||
/// @todo shall we omit this check, since we trust the parsing code?
|
||||
elseif ($_xh['isf'] > 3 || $returnType == XMLParser::RETURN_XMLRPCVALS && !is_object($_xh['value'])) {
|
||||
/// @todo shall we omit the 2nd part of this check, since we trust the parsing code?
|
||||
/// Either that, or check the fault results too...
|
||||
elseif ($_xh['isf'] > 3 || ($returnType == XMLParser::RETURN_XMLRPCVALS && !$_xh['isf'] && !is_object($_xh['value']))) {
|
||||
// something odd has happened and it's time to generate a client side error indicating something odd went on
|
||||
$r = new Response(0, PhpXmlRpc::$xmlrpcerr['xml_parsing_error'], PhpXmlRpc::$xmlrpcstr['xml_parsing_error'],
|
||||
'', $httpResponse
|
||||
|
||||
@@ -45,7 +45,7 @@ class Server
|
||||
/**
|
||||
* @var string
|
||||
* Defines how functions in $dmap will be invoked: either using an xml-rpc Request object or plain php values.
|
||||
* Valid strings are 'xmlrpcvals', 'phpvals' or 'epivals' (only for use by polyfill-xmlrpc).
|
||||
* Valid strings are 'xmlrpcvals', 'phpvals' or 'epivals' (the latter only for use by polyfill-xmlrpc).
|
||||
*
|
||||
* @todo create class constants for these
|
||||
*/
|
||||
@@ -163,7 +163,7 @@ class Server
|
||||
* - docstring (optional)
|
||||
* - signature (array, optional)
|
||||
* - signature_docs (array, optional)
|
||||
* - parameters_type (string, optional)
|
||||
* - parameters_type (string, optional). Valid values: 'phpvals', 'xmlrpcvals'
|
||||
* - exception_handling (int, optional)
|
||||
* @param boolean $serviceNow set to false in order to prevent the server from running upon construction
|
||||
*/
|
||||
@@ -654,7 +654,8 @@ class Server
|
||||
|
||||
// 'guestimate' request encoding
|
||||
/// @todo check if mbstring is enabled and automagic input conversion is on: it might mingle with this check???
|
||||
$reqEncoding = XMLParser::guessEncoding(isset($_SERVER['CONTENT_TYPE']) ? $_SERVER['CONTENT_TYPE'] : '',
|
||||
$parser = $this->getParser();
|
||||
$reqEncoding = $parser->guessEncoding(isset($_SERVER['CONTENT_TYPE']) ? $_SERVER['CONTENT_TYPE'] : '',
|
||||
$data);
|
||||
|
||||
return null;
|
||||
@@ -709,6 +710,9 @@ class Server
|
||||
|
||||
$xmlRpcParser = $this->getParser();
|
||||
try {
|
||||
// NB: during parsing, the actual type of php values built will be automatically switched from
|
||||
// $this->functions_parameters_type to the one defined in the method signature, if defined there. This
|
||||
// happens via the parser making a call to $this->methodNameCallback as soon as it finds the desired method
|
||||
$_xh = $xmlRpcParser->parse($data, $this->functions_parameters_type, XMLParser::ACCEPT_REQUEST, $options);
|
||||
// BC
|
||||
if (!is_array($_xh)) {
|
||||
@@ -846,11 +850,11 @@ class Server
|
||||
$exception_handling = $this->exception_handling;
|
||||
}
|
||||
|
||||
// If debug level is 3, we should catch all errors generated during processing of user function, and log them
|
||||
// as part of response
|
||||
if ($this->debug > 2) {
|
||||
self::$_xmlrpcs_prev_ehandler = set_error_handler(array('\PhpXmlRpc\Server', '_xmlrpcs_errorHandler'));
|
||||
}
|
||||
// We always catch all errors generated during processing of user function, and log them as part of response;
|
||||
// if debug level is 3 or above, we also serialize them in the response as comments
|
||||
self::$_xmlrpcs_prev_ehandler = set_error_handler(array('\PhpXmlRpc\Server', '_xmlrpcs_errorHandler'));
|
||||
|
||||
/// @todo what about using output-buffering as well, in case user code echoes anything to screen?
|
||||
|
||||
try {
|
||||
// Allow mixed-convention servers
|
||||
@@ -909,12 +913,11 @@ class Server
|
||||
// proper error-response
|
||||
switch ($exception_handling) {
|
||||
case 2:
|
||||
if ($this->debug > 2) {
|
||||
if (self::$_xmlrpcs_prev_ehandler) {
|
||||
set_error_handler(self::$_xmlrpcs_prev_ehandler);
|
||||
} else {
|
||||
restore_error_handler();
|
||||
}
|
||||
if (self::$_xmlrpcs_prev_ehandler) {
|
||||
set_error_handler(self::$_xmlrpcs_prev_ehandler);
|
||||
self::$_xmlrpcs_prev_ehandler = null;
|
||||
} else {
|
||||
restore_error_handler();
|
||||
}
|
||||
throw $e;
|
||||
case 1:
|
||||
@@ -932,12 +935,11 @@ class Server
|
||||
// proper error-response
|
||||
switch ($exception_handling) {
|
||||
case 2:
|
||||
if ($this->debug > 2) {
|
||||
if (self::$_xmlrpcs_prev_ehandler) {
|
||||
set_error_handler(self::$_xmlrpcs_prev_ehandler);
|
||||
} else {
|
||||
restore_error_handler();
|
||||
}
|
||||
if (self::$_xmlrpcs_prev_ehandler) {
|
||||
set_error_handler(self::$_xmlrpcs_prev_ehandler);
|
||||
self::$_xmlrpcs_prev_ehandler = null;
|
||||
} else {
|
||||
restore_error_handler();
|
||||
}
|
||||
throw $e;
|
||||
case 1:
|
||||
@@ -952,14 +954,13 @@ class Server
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->debug > 2) {
|
||||
// note: restore the error handler we found before calling the user func, even if it has been changed
|
||||
// inside the func itself
|
||||
if (self::$_xmlrpcs_prev_ehandler) {
|
||||
set_error_handler(self::$_xmlrpcs_prev_ehandler);
|
||||
} else {
|
||||
restore_error_handler();
|
||||
}
|
||||
// note: restore the error handler we found before calling the user func, even if it has been changed
|
||||
// inside the func itself
|
||||
if (self::$_xmlrpcs_prev_ehandler) {
|
||||
set_error_handler(self::$_xmlrpcs_prev_ehandler);
|
||||
self::$_xmlrpcs_prev_ehandler = null;
|
||||
} else {
|
||||
restore_error_handler();
|
||||
}
|
||||
|
||||
return $r;
|
||||
@@ -973,7 +974,7 @@ class Server
|
||||
* @internal
|
||||
* @param $methodName
|
||||
* @param XMLParser $xmlParser
|
||||
* @param resource $parser
|
||||
* @param null|resource $parser
|
||||
* @return void
|
||||
* @throws NoSuchMethodException
|
||||
*
|
||||
@@ -981,7 +982,7 @@ class Server
|
||||
* dirtying a lot the logic, as we would have back to both parseRequest() and execute() methods the info
|
||||
* about the matched method handler, in order to avoid doing the work twice...
|
||||
*/
|
||||
public function methodNameCallback($methodName, $xmlParser, $parser)
|
||||
public function methodNameCallback($methodName, $xmlParser, $parser = null)
|
||||
{
|
||||
$sysCall = $this->isSyscall($methodName);
|
||||
$dmap = $sysCall ? $this->getSystemDispatchMap() : $this->dmap;
|
||||
@@ -997,15 +998,15 @@ class Server
|
||||
/// @todo this should be done by a method of the XMLParser
|
||||
switch ($dmap[$methodName]['parameters_type']) {
|
||||
case XMLParser::RETURN_PHP:
|
||||
xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee_fast');
|
||||
xml_set_element_handler($parser, array($xmlParser, 'xmlrpc_se'), array($xmlParser, 'xmlrpc_ee_fast'));
|
||||
break;
|
||||
case XMLParser::RETURN_EPIVALS:
|
||||
xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee_epi');
|
||||
xml_set_element_handler($parser, array($xmlParser, 'xmlrpc_se'), array($xmlParser, 'xmlrpc_ee_epi'));
|
||||
break;
|
||||
/// @todo log a warning on unsupported return type
|
||||
case XMLParser::RETURN_XMLRPCVALS:
|
||||
default:
|
||||
xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee');
|
||||
xml_set_element_handler($parser, array($xmlParser, 'xmlrpc_se'), array($xmlParser, 'xmlrpc_ee'));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1415,9 +1416,13 @@ class Server
|
||||
return;
|
||||
}
|
||||
|
||||
//if ($errCode != E_NOTICE && $errCode != E_WARNING && $errCode != E_USER_NOTICE && $errCode != E_USER_WARNING)
|
||||
if ($errCode != E_STRICT) {
|
||||
// From PHP 8.4 the E_STRICT constant has been deprecated and will emit deprecation notices.
|
||||
// PHP core and core extensions since PHP 8.0 and later do not emit E_STRICT notices at all.
|
||||
// On PHP 7 series before PHP 7.4, some functions conditionally emit E_STRICT notices.
|
||||
if (PHP_VERSION_ID >= 70400) {
|
||||
static::error_occurred($errString);
|
||||
} elseif ($errCode != E_STRICT) {
|
||||
static::error_occurred($errString);
|
||||
}
|
||||
|
||||
// Try to avoid as much as possible disruption to the previous error handling mechanism in place
|
||||
|
||||
@@ -443,7 +443,6 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess
|
||||
* @param mixed $offset
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
*
|
||||
* @throws ValueErrorException|TypeErrorException
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
@@ -521,7 +520,6 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess
|
||||
*
|
||||
* @param mixed $offset
|
||||
* @return void
|
||||
*
|
||||
* @throws ValueErrorException|StateErrorException
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
|
||||
@@ -66,7 +66,7 @@ class Wrapper
|
||||
case 'true':
|
||||
return Value::$xmlrpcBoolean;
|
||||
case Value::$xmlrpcArray: // 'array':
|
||||
case 'array[]';
|
||||
case 'array[]':
|
||||
return Value::$xmlrpcArray;
|
||||
case 'object':
|
||||
case Value::$xmlrpcStruct: // 'struct'
|
||||
|
||||
@@ -677,7 +677,7 @@ All rights reserved.</copyright>
|
||||
<location>phpxmlrpc</location>
|
||||
<name>phpxmlrpc</name>
|
||||
<description>A php library for building xml-rpc clients and servers</description>
|
||||
<version>4.10.1</version>
|
||||
<version>4.11.1</version>
|
||||
<license>BSD</license>
|
||||
<licenseversion>3-Clause</licenseversion>
|
||||
<repository>https://github.com/gggeek/phpxmlrpc</repository>
|
||||
|
||||
Reference in New Issue
Block a user