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

tool_mobile_call_external_functions seems not handling properly coding exceptions

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.7.6, 3.8.3
    • 3.7.2, 3.8.2, 3.9
    • Web Services
    • MOODLE_37_STABLE, MOODLE_38_STABLE, MOODLE_39_STABLE
    • MOODLE_37_STABLE, MOODLE_38_STABLE
    • MDL-67189-master
    • Hide

      Force an error by modifying Moodle's code

      1. Open the file admin/tool/mobile/classes/external.php.
      2. Search this line:

        $settings = api::get_config($params['section']);

      3. Add a new line right after that one with this code:

        $a = 1 % 0;

      Test the issue

      1. As admin, go to "Site administration > Development > Debugging" and set "Debug messages" to NONE.
      2. Create a new user (Site administration > Users > Accounts > Add a new user).
      3. Enable "Mobile services": Site administration ► Mobile app ► Mobile settings
      4. Create a Token in the mobile app service for the user created in step 2:
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      5. Next, you can do a CURL REST call simulating a WS client with the user.
        • You need to replace the WSTOKEN and the SITEURL of your moodle instance.

          curl 'http://SITEURL/webservice/rest/server.php?moodlewsrestformat=json' --data 'requests[0][arguments]={}&requests[0][function]=core_webservice_get_site_info&requests[0][settingfilter]=1&requests[0][settingfileurl]=1&requests[1][arguments]={}&requests[1][function]=tool_mobile_get_config&requests[1][settingfilter]=1&requests[1][settingfileurl]=1&wsfunction=tool_mobile_call_external_functions&wstoken=WSTOKEN' | python -m "json.tool"

      6. Confirm that after executing the request:
        • You get a "responses" array.
        • The first object in that array has ' "error": false' and a bunch of other data.
        • The second object in that array has ' "error": true' and a "exception". Check that the exception does not have a debuginfo or backtrace property.
      7. As admin, go to "Site administration > Development > Debugging" and set "Debug messages" to DEVELOPER.
      8. Repeat step 5.
      9. Confirm that after executing the request:
        • You get a "responses" array.
        • The first object in that array has ' "error": false' and a bunch of other data.
        • The second object in that array has ' "error": true' and a "exception". Check that the exception has a debuginfo and backtrace property.
      Show
      Force an error by modifying Moodle's code Open the file admin/tool/mobile/classes/external.php . Search this line: $settings = api::get_config($params ['section'] ); Add a new line right after that one with this code: $a = 1 % 0; Test the issue As admin, go to "Site administration > Development > Debugging" and set "Debug messages" to NONE. Create a new user (Site administration > Users > Accounts > Add a new user). Enable "Mobile services": Site administration ► Mobile app ► Mobile settings Create a Token in the mobile app service for the user created in step 2: Click on Site administration ► Plugins ► Web services ► Manage tokens Next, you can do a CURL REST call simulating a WS client with the user. You need to replace the WSTOKEN and the SITEURL of your moodle instance. curl 'http://SITEURL/webservice/rest/server.php?moodlewsrestformat=json' --data 'requests [0] [arguments] ={}&requests [0] [function] =core_webservice_get_site_info&requests [0] [settingfilter] =1&requests [0] [settingfileurl] =1&requests [1] [arguments] ={}&requests [1] [function] =tool_mobile_get_config&requests [1] [settingfilter] =1&requests [1] [settingfileurl] =1&wsfunction=tool_mobile_call_external_functions&wstoken=WSTOKEN' | python -m "json.tool" Confirm that after executing the request: You get a "responses" array. The first object in that array has ' "error": false' and a bunch of other data. The second object in that array has ' "error": true' and a "exception". Check that the exception does not have a  debuginfo or  backtrace property. As admin, go to "Site administration > Development > Debugging" and set "Debug messages" to DEVELOPER. Repeat step 5. Confirm that after executing the request: You get a "responses" array. The first object in that array has ' "error": false' and a bunch of other data. The second object in that array has ' "error": true' and a "exception". Check that the exception has a  debuginfo and  backtrace property.

      MOBILE-3203 was opened because for certain types of exceptions the complete WS request is failed

      This should not be happening because call_external_function() implements exception handling (but maybe is not capturing all possible exceptions). Like when there is a coding exception.

            dpalou Dani Palou
            jleyva Juan Leyva
            Juan Leyva Juan Leyva
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Janelle Barcega Janelle Barcega
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 3 hours, 18 minutes
                3h 18m

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