Commit 715a2ff9 authored by Piers Harding's avatar Piers Harding Committed by Robert Lyon
Browse files

webservices: fix REST web services for cm

Bug 1631810: Web services fixes

* fix json_decode() invalid param warnings
* dont pass functionaname if it's empty

behatnotneeded

Change-Id: I83acba2795fa901613b985a5b82586281b1e5f3c
parent fd22ee72
......@@ -184,7 +184,7 @@ class webservice_rest_client {
}
// default to parsing HTTP parameters
$this->serverurl = $this->serverurl. '?'.$this->auth . '&wsfunction='. $functionname;
$this->serverurl = $this->serverurl . '?' . $this->auth . ($functionname ? '&wsfunction=' . $functionname : '');
$result = webservice_download_file_content($this->serverurl, $this->headers, $params,
false, 300, 20, get_config('disablesslchecks'), null, false, true);
log_debug("REST client response: ".var_export($result, true));
......
......@@ -164,8 +164,12 @@ class webservice_rest_server extends webservice_base_server {
// in oauth, structures are flattened using json
if ($oauth_token) {
foreach ($this->parameters as $key => $value) {
if (json_decode($value, true) !== NULL) {
$this->parameters[$key] = json_decode($value, true);
if (!is_string($value)) {
continue;
}
$decoded = json_decode($value, true);
if (json_last_error() === JSON_ERROR_NONE) {
$this->parameters[$key] = $decoded;
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment