Uploaded image for project: 'phpBB3'
  1. phpBB3
  2. PHPBB3-11912

"Unable to guess the mime type as no guessers are available" when uploading files

    Details

    • Type: Bug
    • Status: Unverified Fix
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 3.1.0-dev
    • Fix Version/s: 3.1.0-a3
    • Component/s: None
    • Labels:
      None

      Description

      <b>Fatal error</b>: Uncaught exception 'LogicException' with message 'Unable to guess the mime type as no guessers are available (Did you enable the php_fileinfo extension?)' in E:\Develop\develop\phpBB\vendor\symfony\http-foundation\Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser.php:123
      Stack trace:
      #0 E:\Develop\develop\phpBB\vendor\symfony\http-foundation\Symfony\Component\HttpFoundation\File\File.php(87): Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser-&gt;guess('./files/pluploa...')
      #1 E:\Develop\develop\phpBB\phpbb\plupload\plupload.php(131): Symfony\Component\HttpFoundation\File\File-&gt;getMimeType('./files/pluploa...')
      #2 E:\Develop\develop\phpBB\includes\functions_upload.php(590): phpbb\plupload\plupload-&gt;handle_upload('fileupload')
      #3 E:\Develop\develop\phpBB\includes\functions_posting.php(427): fileupload-&gt;form_upload('fileupload', Object(phpbb\plupload\plupload))
      #4 E:\Develop\develop\phpBB\includes\message_parser.php(1508): upload_attachment('fileupload', 2, false, '', false, false, Object( in <b>E:\Develop\develop\phpBB\vendor\symfony\http-foundation\Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser.php</b> on line <b>123</b><br />

      The problem is, that the mimetype guesser requires php_fileinfo php extension, but we do not check for it on install/update?

      If possible, we should try whether there are guessers available before calling it, and just dont use the mimetype guesser otherwise.

        Activity

        Hide
        Marc Marc added a comment -

        IMHO the mimetype guesser should fall back to the ContentMimeTypeGuesser that does not require the php_fileinfo extension.

        Show
        Marc Marc added a comment - IMHO the mimetype guesser should fall back to the ContentMimeTypeGuesser that does not require the php_fileinfo extension.
        Hide
        bantu Andreas Fischer added a comment -

        Yes

        Show
        bantu Andreas Fischer added a comment - Yes
        Hide
        Marc Marc added a comment -

        Then there should be at least one mimetype guesser available or am I missing something here?

        Show
        Marc Marc added a comment - Then there should be at least one mimetype guesser available or am I missing something here?
        Hide
        bantu Andreas Fischer added a comment -

        That is my understanding as well.

        Show
        bantu Andreas Fischer added a comment - That is my understanding as well.
        Hide
        Marc Marc added a comment -

        This only seems to happen while uploading a file in chunks.

        Show
        Marc Marc added a comment - This only seems to happen while uploading a file in chunks.
        Hide
        Marc Marc added a comment -

        The ContentTypeMimeTypeGuesser does not exist anymore. It has been removed from the symfony repository but not from the documentation:
        https://github.com/symfony/symfony/commit/ea0db2d6f4d6f378b09ba79bbc800bdecfaad27e

        Due to that, it does make sense that there are no guessers found. The question is whether we want to require people to have the fileinfo extension enabled or if we want to have a fallback for the case if no guesser is available. The fallback would probably just be catching the Exception and returning a dummy mimetype.

        Show
        Marc Marc added a comment - The ContentTypeMimeTypeGuesser does not exist anymore. It has been removed from the symfony repository but not from the documentation: https://github.com/symfony/symfony/commit/ea0db2d6f4d6f378b09ba79bbc800bdecfaad27e Due to that, it does make sense that there are no guessers found. The question is whether we want to require people to have the fileinfo extension enabled or if we want to have a fallback for the case if no guesser is available. The fallback would probably just be catching the Exception and returning a dummy mimetype.
        Hide
        Marc Marc added a comment -

        FWIW, we could catch the exception like this:
        https://gist.github.com/marc1706/7deff4122fd1ba405945

        Show
        Marc Marc added a comment - FWIW, we could catch the exception like this: https://gist.github.com/marc1706/7deff4122fd1ba405945
        Hide
        Marc Marc added a comment -

        We could also create a service that does mimetype guessing for us. That would probably enable us to have a more versatile mimetype guessing with the downside of creating yet another service that does something that is mostly covered by third party plugins or in this case even symfony itself.

        Show
        Marc Marc added a comment - We could also create a service that does mimetype guessing for us. That would probably enable us to have a more versatile mimetype guessing with the downside of creating yet another service that does something that is mostly covered by third party plugins or in this case even symfony itself.
        Hide
        nickvergessen Joas Schilling added a comment -

        Patch needs work, as mentioned on github the collection should use priorities

        Show
        nickvergessen Joas Schilling added a comment - Patch needs work, as mentioned on github the collection should use priorities

          People

          • Assignee:
            EXreaction EXreaction [X] (Inactive)
            Reporter:
            nickvergessen Joas Schilling
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development