- if ((xml_get_current_line_number($parser)) == 1) {
- $errStr = 'XML error at line 1, check URL';
- } else {
- $errStr = sprintf('XML error: %s at line %d, column %d',
- xml_error_string(xml_get_error_code($parser)),
- xml_get_current_line_number($parser), xml_get_current_column_number($parser));
- }
- error_log($errStr);
- $r = new Response(0, PhpXmlRpc::$xmlrpcerr['invalid_return'], PhpXmlRpc::$xmlrpcstr['invalid_return'] . ' (' . $errStr . ')');
- xml_parser_free($parser);
if ($this->debug) {
- print $errStr;
+ print $xmlRpcParser->_xh['isf_reason'];
}
- $r->hdrs = $this->httpResponse['headers'];
- $r->_cookies = $this->httpResponse['cookies'];
- $r->raw_data = $this->httpResponse['raw_data'];
-
- return $r;
}
- xml_parser_free($parser);
// second error check: xml well formed but not xml-rpc compliant
- if ($xmlRpcParser->_xh['isf'] > 1) {
+ elseif ($xmlRpcParser->_xh['isf'] == 2) {
+ $r = new Response(0, PhpXmlRpc::$xmlrpcerr['invalid_return'],
+ PhpXmlRpc::$xmlrpcstr['invalid_return'] . ' ' . $xmlRpcParser->_xh['isf_reason']);
+
if ($this->debug) {
/// @todo echo something for user?
}
-
- $r = new Response(0, PhpXmlRpc::$xmlrpcerr['invalid_return'],
- PhpXmlRpc::$xmlrpcstr['invalid_return'] . ' ' . $xmlRpcParser->_xh['isf_reason']);
}
// third error check: parsing of the response has somehow gone boink.
- // NB: shall we omit this check, since we trust the parsing code?
+ /// @todo shall we omit this check, since we trust the parsing code?
elseif ($returnType == 'xmlrpcvals' && !is_object($xmlRpcParser->_xh['value'])) {
// something odd has happened
// and it's time to generate a client side error
@@ -316,21 +365,19 @@ class Request
$r = new Response(0, PhpXmlRpc::$xmlrpcerr['invalid_return'],
PhpXmlRpc::$xmlrpcstr['invalid_return']);
} else {
- if ($this->debug) {
- $this->debugMessage(
- "---PARSED---\n".var_export($xmlRpcParser->_xh['value'], true)."\n---END---", false
+ if ($this->debug > 1) {
+ $this->getLogger()->debugMessage(
+ "---PARSED---\n".var_export($xmlRpcParser->_xh['value'], true)."\n---END---"
);
}
- // note that using =& will raise an error if $xmlRpcParser->_xh['st'] does not generate an object.
- $v = &$xmlRpcParser->_xh['value'];
+ $v = $xmlRpcParser->_xh['value'];
if ($xmlRpcParser->_xh['isf']) {
- /// @todo we should test here if server sent an int and a string,
- /// and/or coerce them into such...
+ /// @todo we should test here if server sent an int and a string, and/or coerce them into such...
if ($returnType == 'xmlrpcvals') {
- $errNo_v = $v->structmem('faultCode');
- $errStr_v = $v->structmem('faultString');
+ $errNo_v = $v['faultCode'];
+ $errStr_v = $v['faultString'];
$errNo = $errNo_v->scalarval();
$errStr = $errStr_v->scalarval();
} else {
@@ -357,20 +404,22 @@ class Request
}
/**
- * Echoes a debug message, taking care of escaping it when not in console mode
+ * Kept the old name even if Request class was renamed, for compatibility.
*
- * @param string $message
- * @param bool $encodeEntities when false, escapes using htmlspecialchars instead of htmlentities
+ * @return string
*/
- protected function debugMessage($message, $encodeEntities = true)
+ public function kindOf()
{
- if (PHP_SAPI != 'cli') {
- if ($encodeEntities)
- print "\n".htmlentities($message)."\n
";
- else
- print "\n".htmlspecialchars($message)."\n
";
- } else {
- print "\n$message\n";
- }
+ return 'msg';
+ }
+
+ /**
+ * Enables/disables the echoing to screen of the xmlrpc responses received.
+ *
+ * @param integer $level values 0, 1, 2 are supported
+ */
+ public function setDebug($level)
+ {
+ $this->debug = $level;
}
}