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

forum external function get_forum_discussion_posts returns incorrect userprofileurl

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.0.1
    • 3.0.2
    • Forum, Web Services
    • MOODLE_30_STABLE
    • MOODLE_30_STABLE
    •  MDL-52576_user_profile
    • Hide
      1. Create a course with several students/teachers with user pictures (test users created from MDK will do).
      2. Create a forum activity and add a discussion.
      3. Login with the created accounts and post a reply to the discussion.
      4. As admin, enable "Mobile services": Plugins ► Web Services ► Mobile
      5. Create a Token for the admin or any of the created users.
      6. Click on Site administration ► Plugins ► Web services ► Manage tokens
      7. On a terminal, enter the following curl command (replace the values in square brackets accordingly).

        curl 'http://[SERVER_URL_HERE]/webservice/rest/server.php?moodlewsrestformat=json' --data 'discussionid=[DISCUSSION_ID_HERE]&wsfunction=mod_forum_get_forum_discussion_posts&wstoken=[TOKEN_HERE]' --compressed | python -m json.tool

      8. Choose a post from the JSON data and copy the value for userpictureurl field and open it on a browser.
        • Confirm that the displayed picture matches the user associated with the chosen post.
      9. Repeat the above step for the other forum posts.
      10. Edit user_picture::__construct() and change

        $needrec = false;
        

        to

        $needrec = true;
        

        (in or around line 218 of lib/outputcomponents.php).

      11. Run the above curl command on the terminal again.
      12. Choose a post from the JSON data and copy the value for userpictureurl field and open it on a browser.
        • Confirm that the displayed picture matches the user associated with the chosen post.
      13. Repeat the above step for the other forum posts.
      Show
      Create a course with several students/teachers with user pictures (test users created from MDK will do). Create a forum activity and add a discussion. Login with the created accounts and post a reply to the discussion. As admin, enable "Mobile services": Plugins ► Web Services ► Mobile Create a Token for the admin or any of the created users. Click on Site administration ► Plugins ► Web services ► Manage tokens On a terminal, enter the following curl command (replace the values in square brackets accordingly). curl 'http://[SERVER_URL_HERE]/webservice/rest/server.php?moodlewsrestformat=json' --data 'discussionid=[DISCUSSION_ID_HERE]&wsfunction=mod_forum_get_forum_discussion_posts&wstoken=[TOKEN_HERE]' --compressed | python -m json.tool Choose a post from the JSON data and copy the value for userpictureurl field and open it on a browser. Confirm that the displayed picture matches the user associated with the chosen post. Repeat the above step for the other forum posts. Edit user_picture::__construct() and change $needrec = false; to $needrec = true; (in or around line 218 of lib/outputcomponents.php). Run the above curl command on the terminal again. Choose a post from the JSON data and copy the value for userpictureurl field and open it on a browser. Confirm that the displayed picture matches the user associated with the chosen post. Repeat the above step for the other forum posts.

    Description

      forum external function get_forum_discussion_posts returns incorrect userprofileurl
      it calls new user_picture with post id instead of user id, so never returns the right picture.

      Call external function with post replies,
      check the correct user profile url is returned

      Attachments

        Activity

          People

            berserkk Ben Kelada
            berserkk Ben Kelada
            Jun Pataleta Jun Pataleta
            Dan Poltawski Dan Poltawski
            John Okely John Okely
            Adrian Greeve, Ilya Tregubov, Kevin Percy, Mathew May, Mihail Geshoski, Shamim Rezaie, Juan Leyva, David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              11/Jan/16