Affects Version/s: 2.2
Fix Version/s: 2.2.2
Component/s: Web Services
Use the REST client (https://github.com/moodlehq/sample-ws-clients/tree/master/PHP-REST) to call core_role_assign_roles. 'null' should be returned, you should not see any coding error.ShowUse the REST client ( https://github.com/moodlehq/sample-ws-clients/tree/master/PHP-REST ) to call core_role_assign_roles. 'null' should be returned, you should not see any coding error.
Pull from Repository:
Pull Master Branch:
Pull Master Diff URL:
Some Fabio's comments originally in MDL-30878 that concerns a Coding error exception with core_role_assign_roles
About the return value, returning null actually causes an execution error (at least on my installations).
I took this example from the forum, but the error is the same.
<MESSAGE>Coding error detected, it must be fixed by a programmer:
PHP catchable fatal error</MESSAGE>
<DEBUGINFO>Argument 1 passed to external_api::clean_returnvalue()
must be an instance of external_description, null given, called in
/var/www/moodle/moodle/webservice/rest/locallib.php on line 88 and
What happens is that on the webservice definition, the update_users_returns() is returning null, but a structure of the type external_description must be returned always (or at least, that is what I understand).
This is why I've returned the id's instead of null.
I would like to know what is your opinion about this. Another user has complained already, because a lot of webservice functions are declaring their return values as null, which raises these errors and break the webservices output, even though they do what they are supposed to do. This forum discussion is an example: http://moodle.org/mod/forum/discuss.php?d=193402
I have seen that this behavior differs on the 2.1 implementation.
This is why it works on 2.1 but not on 2.2: the response generator is different on each version, and on 2.2 version it does not accept null as a return value.
So it actually seems more like a bug on the response generator then on the webservice definitions, as I thought it was.