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

tool_mobile_call_external_functions seems not handling properly coding exceptions

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.7.2, 3.8.2, 3.9
    • Fix Version/s: 3.7.6, 3.8.3
    • Component/s: Web Services
    • Labels:
    • Testing Instructions:
      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.
    • Affected Branches:
      MOODLE_37_STABLE, MOODLE_38_STABLE, MOODLE_39_STABLE
    • Fixed Branches:
      MOODLE_37_STABLE, MOODLE_38_STABLE
    • Pull from Repository:
    • Pull 3.7 Branch:
    • Pull 3.8 Branch:
    • Pull Master Branch:
      MDL-67189-master

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              dpalou Dani Palou
              Reporter:
              jleyva Juan Leyva
              Peer reviewer:
              Juan Leyva
              Integrator:
              Eloy Lafuente (stronk7)
              Tester:
              Janelle Barcega
              Participants:
              Component watchers:
              Juan Leyva, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                11/May/20

                  Time Tracking

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