mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 01:16:44 +02:00
MDL-37355 object are automatically cast into object by the return value
This commit is contained in:
parent
9da506c2a3
commit
9a4c2f50c9
2 changed files with 69 additions and 2 deletions
|
@ -266,10 +266,16 @@ class external_api {
|
|||
}
|
||||
|
||||
} else if ($description instanceof external_single_structure) {
|
||||
if (!is_array($response)) {
|
||||
throw new invalid_response_exception('Only arrays accepted. The bad value is: \'' .
|
||||
if (!is_array($response) && !is_object($response)) {
|
||||
throw new invalid_response_exception('Only arrays/objects accepted. The bad value is: \'' .
|
||||
print_r($response, true) . '\'');
|
||||
}
|
||||
|
||||
// Cast objects into arrays.
|
||||
if (is_object($response)) {
|
||||
$response = (array) $response;
|
||||
}
|
||||
|
||||
$result = array();
|
||||
foreach ($description->keys as $key=>$subdesc) {
|
||||
if (!array_key_exists($key, $response)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue