jsonrpc
jsonrpc copied to clipboard
Optionals parameters shifted if missing in request
Parameters are ordered by name, but optional parameters not present in request are not handled and the parameters are shifted.
With the function :
updateUser($password = null, $email = null, $receiveEmail = null)
request :
"params":{"receiveEmail":false, "email":"[email protected]"}
bad call :
updateUser("[email protected]", false)
The server ordered well the parameters, but miss the first optional one and call the function with the list receive.
Anyway, thanks for this great bundle, Vincent.
I've solved the problem by modifying function checkMethod in Server.php.
foreach ($refParams as $arg)
{
$argName = $arg->getName();
if (array_key_exists($argName, $named))
{
$params[] = $named[$argName];
unset($named[$argName]);
}
else
{
if (!$arg->isOptional())
{
$res = false;
break;
} else {
$params[] = $arg->getDefaultValue();
}
}
}
Hope it helps!