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

Web service function get_users_by_field does not return appropriate fields

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. Login as admin
      2. Create a new user leaving as many fields blank as possible
        • Note its user name for later (substitute for the USERNAME in the CLI commands below)
      3. Go to Site administration ► Plugins ► Web services ► Mobile and tick Enable web services for mobile devices
      4. Create an external service in which core_user_get_users_by_field is added (You may also skip this and just use the built-in Moodle mobile web service)
      5. Go to Site administration ► Plugins ► Web services ► Manage tokens
      6. Create a token for the admin user in that service
      7. Open a terminal window in which you'll observe your Apache error log
        • Typically: {tail -f /var/log/apache2/error.log}
      8. Request the following:

        // Using HTTPie
        http -f WWWROOT/webservice/rest/server.php wstoken=TOKEN wsfunction=core_user_get_users_by_field field=username values[0]=USERNAME moodlewsrestformat=xml
         
        // Using curl
        curl WWWROOT/webservice/rest/server.php -d wstoken=TOKEN -d wsfunction=core_user_get_users_by_field -d field=username -d values[0]=USERNAME -d moodlewsrestformat=xml
        

      9. Confirm that there aren't any notices/errors about missing indexes in the logs
      10. Confirm that the XML structure is not broken (does not contain notices either)
      Show
      Login as admin Create a new user leaving as many fields blank as possible Note its user name for later (substitute for the USERNAME in the CLI commands below) Go to Site administration ► Plugins ► Web services ► Mobile and tick Enable web services for mobile devices Create an external service in which core_user_get_users_by_field is added (You may also skip this and just use the built-in Moodle mobile web service ) Go to Site administration ► Plugins ► Web services ► Manage tokens Create a token for the admin user in that service Open a terminal window in which you'll observe your Apache error log Typically: {tail -f /var/log/apache2/error.log} Request the following: // Using HTTPie http -f WWWROOT/webservice/rest/server.php wstoken=TOKEN wsfunction=core_user_get_users_by_field field=username values[0]=USERNAME moodlewsrestformat=xml   // Using curl curl WWWROOT/webservice/rest/server.php -d wstoken=TOKEN -d wsfunction=core_user_get_users_by_field -d field=username -d values[0]=USERNAME -d moodlewsrestformat=xml Confirm that there aren't any notices/errors about missing indexes in the logs Confirm that the XML structure is not broken (does not contain notices either)
    • Workaround:
      Hide

      Request the JSON format. Add moodlewsrestformat=json to the request.

      Show
      Request the JSON format. Add moodlewsrestformat=json to the request.
    • Affected Branches:
      MOODLE_27_STABLE, MOODLE_30_STABLE
    • Fixed Branches:
      MOODLE_30_STABLE, MOODLE_31_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-46934-master

      Description

      The web services function get_users_by_field for core_user_get_users_by_field does not return the full field list. This causes missing field warnings as the result set is serialised and returned.

        Attachments

          Activity

            People

            Assignee:
            fred Frédéric Massart
            Reporter:
            piers Piers Harding
            Peer reviewer:
            Jun Pataleta
            Integrator:
            David Monllaó
            Tester:
            Adrian Greeve
            Participants:
            Component watchers:
            Juan Leyva, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
            Votes:
            2 Vote for this issue
            Watchers:
            7 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              11/Jul/16