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

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

XMLWordPrintable

    • MOODLE_33_STABLE, MOODLE_34_STABLE, MOODLE_35_STABLE
    • MOODLE_33_STABLE, MOODLE_34_STABLE
    • MDL-60738-master
    • 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

      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)

            jleyva Juan Leyva
            jleyva Juan Leyva
            Simey Lameze Simey Lameze
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Mark Nelson Mark Nelson
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

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