Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-31077

REST server fails to return null

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Blocker Blocker
    • 2.2.2
    • 2.2
    • Web Services

      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.

      <EXCEPTION class="coding_exception">
      <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
      defined</DEBUGINFO>
      </EXCEPTION>

      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.

            jerome Jérôme Mouneyrac
            jerome Jérôme Mouneyrac
            Aparup Banerjee Aparup Banerjee
            Sam Hemelryk Sam Hemelryk
            Gerard Caulfield Gerard Caulfield
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.