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

Fix and improve mimetype detection for external file systems

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.3
    • Fix Version/s: 3.4
    • Component/s: Files API
    • Labels:
    • Testing Instructions:
      Hide

      To test first change:

      1. Turn debugging on to Developer.
      2. Setup an external file system.
      3. Create a file activity, upload a file with no extension. Save activity.
      4. Edit the activity (prior to any changes, you will actually see the same below error on this page). Rename the file and save.

      Prior to the change, you will see in the error log that the mimetype functions produced an error. Should look like this:

      PHP Warning:  finfo::file(): Failed identify data 0:invalid mode 00 in /vagrant/www/moodle/lib/filestorage/file_storage.php on line 2106
      

      To test the second change, ensure that mimetypes update when the file name or file contents change, EG:

      1. Create a file activity, upload a file with no extension. Save activity.
      2. Edit the activity. Rename the file and add an extension and save.

      The mimetype information should be updated.

      Show
      To test first change: Turn debugging on to Developer. Setup an external file system. Create a file activity, upload a file with no extension. Save activity. Edit the activity (prior to any changes, you will actually see the same below error on this page). Rename the file and save. Prior to the change, you will see in the error log that the mimetype functions produced an error. Should look like this: PHP Warning: finfo::file(): Failed identify data 0:invalid mode 00 in /vagrant/www/moodle/lib/filestorage/file_storage.php on line 2106 To test the second change, ensure that mimetypes update when the file name or file contents change, EG: Create a file activity, upload a file with no extension. Save activity. Edit the activity. Rename the file and add an extension and save. The mimetype information should be updated.
    • Affected Branches:
      MOODLE_33_STABLE
    • Fixed Branches:
      MOODLE_34_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-59960_mimetype

      Description

      Essentially there are two problems:

      • The mimetype functions in file_system class use external path for file path which is not supported by PHP's finfo class.
      • Every time a file is updated, the mimetype is re-freshed. For files that must be on disk in order to detect the mimetype, this can cause a lot of unnecessary file downloads from the external file system.

        Attachments

          Activity

            People

            Assignee:
            bushido Mark Nielsen
            Reporter:
            bushido Mark Nielsen
            Peer reviewer:
            Sam Chaffee
            Integrator:
            Dan Poltawski
            Tester:
            Jake Dallimore
            Participants:
            Component watchers:
            Matteo Scaramuccia, Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              13/Nov/17