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

maxbytes value incorrectly set when update_courses web service called

XMLWordPrintable

    • MOODLE_31_STABLE, MOODLE_34_STABLE, MOODLE_35_STABLE
    • MOODLE_34_STABLE, MOODLE_35_STABLE
    • MDL-54830-master
    • Easy
    • Hide
      1. Set up a web service (https://docs.moodle.org/35/en/Using_web_services#Creating_a_service) with core_course_updated_courses and a token for the admin user.
      2. Make sure your php config has the post_max_size and upload_max_filesize both set to 8M
      3. Set "Maximum uploaded file size" (maxbytes) to 2MB for the Moodle install via admin
      4. Now, create a new course and save.
      5. Check the "Files and uploads" settings for the course and verify it's set to "site upload limit (2M)"
      6. Try to upload a 3M file to the course home (drag and drop) and verify it fails. Normal, as we've got a 2M limit right now.
      7. Now, run the webservice call:

        curl 'http://localhost/master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_course_update_courses&wstoken=TOKEN&courses[0][id]=COURSEID&courses[0][maxbytes]=0' | python -m "json.tool"
        

        swapping in your token and courseid as needed.

      1. Check the course settings and notice that maxbytes is now set to the site limit as before.
      2. Check the mdl_course table and notice that maxbytes has been set to 0
      3. Now, change the "Maximum uploaded file size" (maxbytes) to 5MB for the Moodle install via admin again.
      4. Check the course settings again, and notice the maxbytes is still set to "Site limit (5M)".
      5. Upload the 3M file again, and verify the upload is successful.
      6. Now, run the web service call again, this time setting maxbytes to 99999999 
      7. Check the course settings and verify the max upload size is listed as 5MB (i.e. it has been capped at the site limit).
      Show
      Set up a web service ( https://docs.moodle.org/35/en/Using_web_services#Creating_a_service ) with core_course_updated_courses and a token for the admin user. Make sure your php config has the post_max_size and upload_max_filesize both set to 8M Set "Maximum uploaded file size" (maxbytes) to 2MB for the Moodle install via admin Now, create a new course and save. Check the "Files and uploads" settings for the course and verify it's set to "site upload limit (2M)" Try to upload a 3M file to the course home (drag and drop) and verify it fails. Normal, as we've got a 2M limit right now. Now, run the webservice call: curl 'http://localhost/master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_course_update_courses&wstoken=TOKEN&courses[0][id]=COURSEID&courses[0][maxbytes]=0' | python -m "json.tool" swapping in your token and courseid as needed. Check the course settings and notice that maxbytes is now set to the site limit as before. Check the mdl_course table and notice that maxbytes has been set to 0 Now, change the "Maximum uploaded file size" (maxbytes) to 5MB for the Moodle install via admin again. Check the course settings again, and notice the maxbytes is still set to "Site limit (5M)". Upload the 3M file again, and verify the upload is successful. Now, run the web service call again, this time setting maxbytes to 99999999  Check the course settings and verify the max upload size is listed as 5MB (i.e. it has been capped at the site limit).

      Description

      By default, maxbytes value in database mdl_course is set to 0 (zero) meaning to use the site upload limit (dynamically).

      But when I call "core_course_update_courses" & pass maxbytes value as 0 (zero). WS is updating the database with calculated bytes value of the current site upload limit instead of updating as zero.

      Impact - affected course does not dynamically use the site upload limit if changed in future

      To replicate:

      1. Set up a web service (https://docs.moodle.org/35/en/Using_web_services#Creating_a_service) with core_course_updated_courses and a token for the admin user.
      2. Make sure your php config has the post_max_size and upload_max_filesize both set to 8M
      3. Set "Maximum uploaded file size" (maxbytes) to 2MB for the Moodle install via admin
      4. Now, create a new course and save.
      5. Check the "Files and uploads" settings for the course and verify it's set to "site upload limit (2M)"
      6. Try to upload a 3M file to the course home (drag and drop) and verify it fails. Normal, as we've got a 2M limit right now.
      7. Now, run the webservice call:

        curl 'http://localhost/master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_course_update_courses&wstoken=TOKEN&courses[0][id]=COURSEID&courses[0][maxbytes]=0' | python -m "json.tool"
        

        swapping in your token and courseid as needed.

      8. Check the course settings and notice that maxbytes is now set to 2M, not the site limit as before.
      9. Check the mdl_course table and notice that maxbytes has been set to 2097152, not 0!
      10. Now, change the "Maximum uploaded file size" (maxbytes) to 5MB for the Moodle install via admin again.
      11. Check the course settings again, and notice the maxbytes is still set to 2M.

            jaked Jake Dallimore
            kunmans Manjunath Moodle
            Jun Pataleta Jun Pataleta
            David Monllaó David Monllaó
            David Carrillo David Carrillo
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

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