MimeTypeGuesser::guess() is deprecated

Created on 29 September 2023, about 1 year ago
Updated 13 December 2023, 12 months ago

In Drupal 10 MimeTypeGuesser::guess() is replaced by MimeTypeGuesser::guessMimeType().

https://www.drupal.org/node/3126004

🐛 Bug report
Status

RTBC

Version

2.0

Component

Code

Created by

🇭🇺Hungary czigor

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @czigor
  • Status changed to Needs review about 1 year ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    19 pass
  • Status changed to RTBC about 1 year ago
  • 🇳🇱Netherlands timohuisman Leiden, Netherlands

    Can confirm that this resolved the issue on Drupal 10.1.5.

  • 🇧🇬Bulgaria pfrenssen Sofia

    RTBC+1, thanks!

  • 🇷🇸Serbia vaish

    Patch #2 fixes the issue for me. However, I don't think if condition in the patch is necessary. Service file.mime_type.guesser is provided by the class Drupal\Core\File\MimeType\MimeTypeGuesser which implements interface Symfony\Component\Mime\MimeTypeGuesserInterface. I don't see an opportunity to ever get anything else.

    This should be sufficient:

    -      $image->filemime = \Drupal::service('file.mime_type.guesser')->guess($image_path);
    +      $image->filemime = \Drupal::service('file.mime_type.guesser')->guessMimeType($image_path);
    
  • 🇭🇺Hungary czigor

    @vaish In Drupal core < 10 this was not the case. The if condition is needed to not break backward compatibility.

  • 🇷🇸Serbia vaish

    @czigor You are right, I did overlook backward compatibility. However, Drupal 9 should not be a problem, unless you are on a very old version. Method ::guessMimeType() is available since Drupal 9.1 (but not in Drupal 9.0). So problem exists with Drupal 9.0 and 8.x and I did overlook that this module still claims the compatibility with Drupal 8.9.

    Drupal 9: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21File%21Mi...

Production build 0.71.5 2024