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

Upload maximum settings are not always followed while $CFG->maxbytes is set to a different value

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. Edit the php config and set post_max_size to 92M while upload_max_filesize is 128M
      2. Restart your server
      3. Install new moodle site
      4. Ensure the "Maximum uploaded file size" (maxbytes) setting at Site admin > Security > Site policies is set to "Server limit" (default)
      5. Check the value at Site admin > Courses > Course default settings and make sure no warning should appear and it's set to 92M
      6. Edit the php config and set post_max_size to 8M while upload_max_filesize is 128M
      7. Restart your server
      8. Check the value at Site admin > Courses > Course default settings (there should be an error next to maxbytes)
      9. Save the default course values
      10. Edit the php config and set post_max_size to 92M while upload_max_filesize is 128M
      11. Restart your server
      12. Check the value at Site admin > Courses > Course default settings (there should be no error next to maxbytes)
      13. Save the default course values
      14. Now change site "Maximum uploaded file size" (maxbytes) setting at Site admin > Security > Site policies to "92M" (Max)
      15. Check the value at Site admin > Courses > Course default settings (there should be no error next to maxbytes and it should be 92M)
      16. Change site "Maximum uploaded file size" (maxbytes) setting at Site admin > Security > Site policies to "50M"
      17. Check the value at Site admin > Courses > Course default settings (there should be error next to maxbytes)
      18. Save the default course value (50M)
      19. Change site "Maximum uploaded file size" (maxbytes) setting at Site admin > Security > Site policies to "92M"
      20. Check the value at Site admin > Courses > Course default settings (there should be no error next to maxbytes)
      Show
      Edit the php config and set post_max_size to 92M while upload_max_filesize is 128M Restart your server Install new moodle site Ensure the "Maximum uploaded file size" (maxbytes) setting at Site admin > Security > Site policies is set to "Server limit" (default) Check the value at Site admin > Courses > Course default settings and make sure no warning should appear and it's set to 92M Edit the php config and set post_max_size to 8M while upload_max_filesize is 128M Restart your server Check the value at Site admin > Courses > Course default settings (there should be an error next to maxbytes) Save the default course values Edit the php config and set post_max_size to 92M while upload_max_filesize is 128M Restart your server Check the value at Site admin > Courses > Course default settings (there should be no error next to maxbytes) Save the default course values Now change site "Maximum uploaded file size" (maxbytes) setting at Site admin > Security > Site policies to "92M" (Max) Check the value at Site admin > Courses > Course default settings (there should be no error next to maxbytes and it should be 92M) Change site "Maximum uploaded file size" (maxbytes) setting at Site admin > Security > Site policies to "50M" Check the value at Site admin > Courses > Course default settings (there should be error next to maxbytes) Save the default course value (50M) Change site "Maximum uploaded file size" (maxbytes) setting at Site admin > Security > Site policies to "92M" Check the value at Site admin > Courses > Course default settings (there should be no error next to maxbytes)
    • Workaround:
      Hide

      Ensure post_max_size and upload_max_filesize match in the PHP config file (e.g. php/php.ini).

      Upload maximum values might need to be reset starting at the site, then course default, then course level.

      Show
      Ensure post_max_size and upload_max_filesize match in the PHP config file (e.g. php/php.ini). Upload maximum values might need to be reset starting at the site, then course default, then course level.
    • Affected Branches:
      MOODLE_19_STABLE, MOODLE_21_STABLE, MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE
    • Pull Master Branch:
      wip-mdl-30667

      Description

      The course default settings page (Site admin > Courses > Course default settings) allows an admin to set the default maximum upload size for a course. The values used for this setting are drawn from an array in get_max_upload_sizes() and also, where it is not present in the array, from the $CFG->maxbytes, which is set at installation based on the upload_max_filesize set by PHP.

      However, the site maximum upload, which defaults to the server maximum, is based on two variables post_max_size and upload_max_filesize. If these two values differ (when compared in the same scale) it chooses the lower, which, at least in XAMPP, is post_max_size.

      So the difference between these two PHP variables causes a conflict which can be quite confusing.

      Under the XAMPP defaults, when upload_max_filesize is 128MB (134217728 bytes) and post_max_size is 8MB, the course default settings page reports that the current value of the default course maximum upload size (moodlecourse | maxbytes) is invalid (see screen capture) because 128MB is not included in the list.

      The initial value of $CFG->maxbytes should be set based on both post_max_size and upload_max_filesize. The site maximum describes that this is the case, so that's good, but the values lower in the hierarchy should clearly state the dependancies involved and what needs to be changed to correctly set a maximum.

      Replication steps:

      1. Ensure the "Maximum uploaded file size" (maxbytes) setting at Site admin > Security > Site policies is set to "Server limit" (default)
      2. Check the value at Site admin > Courses > Course default settings
      3. Edit the php config and set post_max_size to 8M while upload_max_filesize is 128M
      4. Restart your server
      5. Check the value at Site admin > Courses > Course default settings (there may be an error reported at this stage)
      6. Save the default course values
      7. Edit the php config and set post_max_size to 128M while upload_max_filesize is 128M
      8. Check the value at Site admin > Courses > Course default settings (there may be an error reported at this stage)
      9. Save the default course values
      10. Possibly try other combinations so that $CFG->maxbytes does not appear in the list of options

        Attachments

        1. 1577.diff
          2 kB
        2. screenshot-1.jpg
          screenshot-1.jpg
          152 kB
        3. screenshot-2.jpg
          screenshot-2.jpg
          49 kB

          Issue Links

            Activity

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  12/Nov/12