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

Web service functions report errors even though they have worked. Perhaps because they are not checking returned values properly.

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Duplicate
    • Affects Version/s: 2.2
    • Fix Version/s: None
    • Component/s: Web Services
    • Labels:
      None
    • Environment:
      Not relevant.
    • Database:
      Any
    • Testing Instructions:
      Hide

      Run the PHP program that I've attached, after changing some values as explained in the comments at the top. I've also linked it from the URL field in this form.

      Show
      Run the PHP program that I've attached, after changing some values as explained in the comments at the top. I've also linked it from the URL field in this form.
    • Workaround:
      Hide

      I suspect that we can work round it by checking whether the XML returned by these functions contains this string: "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". If it does, call other functions to check Moodle's state and see whether the call did in fact succeed.

      Show
      I suspect that we can work round it by checking whether the XML returned by these functions contains this string: "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". If it does, call other functions to check Moodle's state and see whether the call did in fact succeed.
    • Affected Branches:
      MOODLE_22_STABLE

      Description

      Moodle 2.2 reports errors even when Web-service functions have worked. See the discussion at http://moodle.org/mod/forum/discuss.php?d=193402 , "Am I calling core_role_assign_roles correctly? What do these errors mean?". I have discovered this to be a problem with core_user_delete_users, core_role_assign_roles, and enrol_manual_enrol_users. The message I get, as XML, is:
      <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>
      It probably affects other functions that return values.

      My hypothesis, explained in detail in my January 7 2012 posting to the above thread, is that Moodle checks the values returned by Web-service functions against some kind of template, probably a specification of their allowed types, keys, and values. This check is failing, perhaps because the template is missing or corrupt. Consequently, the Web-service interface reports that the functions have returned something illegal.

      I suspect that the error is reported by the catch-all error trap at the end of the function clean_returnvalue in lib/externallib.php. That is, by this statement:
      throw new invalid_response_exception('Invalid external api response description');

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: