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

Clean 'theme' and 'lang' properties when are returned via WS

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.3.2, 3.4, 3.5
    • Fix Version/s: 3.3.4, 3.4.1
    • Component/s: Web Services
    • Labels:
    • Testing Instructions:
      Hide
      1. As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings
      2. Enable allowuserthemes, allowcoursethemes and allowcategorythemes admin settings
      3. In the frontpageloggedin admin setting enable Combo list and list categories
      4. Create a new category and a new course inside the category
      5. Enrol one user as student or teacher in the new course created
      6. Now, in the Moodle database edit the category, course and user tables changing the "lang" and "theme" fields to a random value like "abcdefg" for the new created category, course and user (note that category doesn't have a lang field)
      7. Go to the site admin and purge caches
      8. Access using the app to the site using the new user account
      9. Go to the Site home and browse to the category, course and access the course contents and course participants
      10. Go again to the app main page (Site home, or dashboard) and click on the user image at the top to open the user profile
      11. Everything should work fine
      Show
      As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings Enable allowuserthemes, allowcoursethemes and allowcategorythemes admin settings In the frontpageloggedin admin setting enable Combo list and list categories Create a new category and a new course inside the category Enrol one user as student or teacher in the new course created Now, in the Moodle database edit the category, course and user tables changing the "lang" and "theme" fields to a random value like "abcdefg" for the new created category, course and user (note that category doesn't have a lang field) Go to the site admin and purge caches Access using the app to the site using the new user account Go to the Site home and browse to the category, course and access the course contents and course participants Go again to the app main page (Site home, or dashboard) and click on the user image at the top to open the user profile Everything should work fine
    • Affected Branches:
      MOODLE_33_STABLE, MOODLE_34_STABLE, MOODLE_35_STABLE
    • Fixed Branches:
      MOODLE_33_STABLE, MOODLE_34_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-60738-master

      Description

      This is a typical problem in the mobile app that needs addressing.

      Sometimes the "theme" and "lang" fields in the user and course tables in the database are set to incorrect values (uninstalled or non-existent themes and language packs). This makes Web Services functions to fail because the WS server validate the returned data using the validate_param function that clean parameters.

      Typical error is:

      {"exception":"invalid_response_exception","errorcode":"invalidresponse","message":"Invalid response value v\u00e1lido","debuginfo":"theme => Invalid response value: Invalid external api response: the value is \"binarius\", the server was expecting \"theme\" type" }

      It usually happens in sites upgraded from old Moodle sites where themes or language packs were uninstalled or in sites where some data (like user profile fields) is sync with external systems (LDAP or database).

      The only way to fix this is not trusting the data coming from DB and clean the theme and lang parameters before they are returned by the WS (so the validate_param function doesn't throw an exception)

        Attachments

          Activity

            People

            Assignee:
            jleyva Juan Leyva
            Reporter:
            jleyva Juan Leyva
            Peer reviewer:
            Simey Lameze
            Integrator:
            Eloy Lafuente (stronk7)
            Tester:
            Mark Nelson
            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:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              15/Jan/18