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

get_forum_discussion_posts doesn't format correctly output vars that may or may not boolean

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.8
    • Fix Version/s: 2.7.3
    • Component/s: Forum, Web Services
    • Labels:
    • Testing Instructions:
      Hide
      1. Inside a course create a forum with a couple of discussions, create a couple of posts in each discussion.
      2. Enable the tracking option for that forum. Ensure that in your user settings/preference you don't have forum tracking disabled
      3. In the database modify the "modified" field of two the posts created, you need to add a timestamp there of two/three days ago
      4. Enable "Mobile services": Plugins ► Web Services ► External services
      5. Create a Token:
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      6. Click add, select user and the Mobile app service
      7. Next, you can do a CURL REST call simulating a WS client:
        • You need to replace the discussionid with the discussions where you added the posts. (You will have to do two curl executions, one for each discussion)
        • You also need to replace the wstoken and the URL of your moodle instance

          curl 'https://moodle.org/webservice/rest/server.php?moodlewsrestformat=json' -H 'pragma: no-cache' -H 'origin: file://' -H 'accept-encoding: gzip,deflate,sdch' -H 'accept-language: es,en;q=0.8,de-DE;q=0.6,de;q=0.4' -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1798.0 Safari/537.36' -H 'content-type: application/x-www-form-urlencoded; charset=UTF-8' -H 'accept: application/json, text/javascript, */*; q=0.01' -H 'cache-control: no-cache' -H 'cookie: __cfduid=dd8421454a753dfc46c3c88cd4fdc24cb1393321120126; __utma=43082041.2075192827.1405091082.1405091082.1405091082.1; __utmz=43082041.1405091082.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); MoodleSession=kpc0nsnkqc76iucppm5uok4va4' --data 'discussionid=273771&wsfunction=mod_forum_get_forum_discussion_posts&wstoken=19aa5a7a60576f82db48bf21e5cb0c96' --compressed
          

      8. Confirm that:
        • The result of that curl call is a json string containing the posts in the discussion, you can use jsonlint.com for validating and formatting the json string
      Show
      Inside a course create a forum with a couple of discussions, create a couple of posts in each discussion. Enable the tracking option for that forum. Ensure that in your user settings/preference you don't have forum tracking disabled In the database modify the "modified" field of two the posts created, you need to add a timestamp there of two/three days ago Enable "Mobile services": Plugins ► Web Services ► External services Create a Token: Click on Site administration ► Plugins ► Web services ► Manage tokens Click add, select user and the Mobile app service Next, you can do a CURL REST call simulating a WS client: You need to replace the discussionid with the discussions where you added the posts. (You will have to do two curl executions, one for each discussion) You also need to replace the wstoken and the URL of your moodle instance curl 'https://moodle.org/webservice/rest/server.php?moodlewsrestformat=json' -H 'pragma: no-cache' -H 'origin: file://' -H 'accept-encoding: gzip,deflate,sdch' -H 'accept-language: es,en;q=0.8,de-DE;q=0.6,de;q=0.4' -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1798.0 Safari/537.36' -H 'content-type: application/x-www-form-urlencoded; charset=UTF-8' -H 'accept: application/json, text/javascript, */*; q=0.01' -H 'cache-control: no-cache' -H 'cookie: __cfduid=dd8421454a753dfc46c3c88cd4fdc24cb1393321120126; __utma=43082041.2075192827.1405091082.1405091082.1405091082.1; __utmz=43082041.1405091082.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); MoodleSession=kpc0nsnkqc76iucppm5uok4va4' --data 'discussionid=273771&wsfunction=mod_forum_get_forum_discussion_posts&wstoken=19aa5a7a60576f82db48bf21e5cb0c96' --compressed Confirm that: The result of that curl call is a json string containing the posts in the discussion, you can use jsonlint.com for validating and formatting the json string
    • Affected Branches:
      MOODLE_28_STABLE
    • Fixed Branches:
      MOODLE_27_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-47916-master

      Description

      This is a strange issue caused by values returned by the core function:
      forum_get_all_discussion_posts

      It seems that some times that core function returns a postread attribute with values true, false or the ID of the row in the forum_read table

      I don't understand very well what is the reason, but in any case, the external function should format the returned value of this function in order to ensure that the returned value is a boolean

      Note: This was detected when testing the Mobile app with moodle.org

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                10/Nov/14