Skip to content

Commit ef3b6e1

Browse files
committed
make client parsing of multicall response more robust for a very specific case
1 parent e135c62 commit ef3b6e1

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/Client.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,6 +1657,7 @@ protected function _try_multicall($reqs, $timeout, $method)
16571657

16581658
if ($this->return_type == 'xml') {
16591659
for ($i = 0; $i < count($reqs); $i++) {
1660+
/// @todo can we do better? we set the complete xml into each response...
16601661
$response[] = new static::$responseClass($rets, 0, '', 'xml', $result->httpResponse());
16611662
}
16621663

@@ -1749,17 +1750,17 @@ protected function _try_multicall($reqs, $timeout, $method)
17491750
'phpvals', $result->httpResponse());
17501751
}
17511752
/** @var Value $code */
1752-
$code = $val['faultCode'];
1753-
if ($code->kindOf() != 'scalar' || $code->scalarTyp() != 'int') {
1753+
$code = @$val['faultCode'];
1754+
if (!$code || $code->kindOf() != 'scalar' || $code->scalarTyp() != 'int') {
17541755
return new static::$responseClass(0, PhpXmlRpc::$xmlrpcerr['multicall_error'],
17551756
PhpXmlRpc::$xmlrpcstr['multicall_error'] . ": response element $i has invalid or no faultCode",
17561757
'xmlrpcvals', $result->httpResponse());
17571758
}
17581759
/** @var Value $str */
1759-
$str = $val['faultString'];
1760-
if ($str->kindOf() != 'scalar' || $str->scalarTyp() != 'string') {
1760+
$str = @$val['faultString'];
1761+
if (!$str || $str->kindOf() != 'scalar' || $str->scalarTyp() != 'string') {
17611762
return new static::$responseClass(0, PhpXmlRpc::$xmlrpcerr['multicall_error'],
1762-
PhpXmlRpc::$xmlrpcstr['multicall_error'] . ": response element $i has invalid or no faultCode",
1763+
PhpXmlRpc::$xmlrpcstr['multicall_error'] . ": response element $i has invalid or no faultString",
17631764
'xmlrpcvals', $result->httpResponse());
17641765
}
17651766
$response[] = new static::$responseClass(0, $code->scalarVal(), $str->scalarVal(), 'xmlrpcvals', $result->httpResponse());

0 commit comments

Comments
 (0)