Drupal 10 / Symfony 6 upgrade. SMTPMailSystem::__construct() $mime_type_guesser parameter wrong typehint

Created on 6 April 2023, over 1 year ago
Updated 21 June 2023, over 1 year ago

Problem/Motivation

While working on upgrades to Drupal 10 Upgrade status provided these errors as needing to be resolved manually:

FILE: web/modules/contrib/smtp/src/Plugin/Mail/SMTPMailSystem.php

STATUS         LINE                           MESSAGE
--------------------------------------------------------------------------------
Check manually 120  Parameter $mime_type_guesser of method
                    Drupal\smtp\Plugin\Mail\SMTPMailSystem::__construct() has
                    typehint with deprecated interface
                    Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuess
                    erInterface: since Symfony 4.3, use {@link
                    MimeTypesInterface} instead
--------------------------------------------------------------------------------

Steps to reproduce

Proposed resolution

Use \Symfony\Component\Mime\MimeTypeGuesserInterface in the docblock

Remaining tasks

Use MimeTypeGuesserInterface typehint for $mime_type_guesser constructor parameter

📌 Task
Status

Postponed

Version

1.0

Component

Code

Created by

🇨🇦Canada klimp Montréal, QC

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

Comments & Activities

  • Issue created by @klimp
  • 🇨🇦Canada klimp Montréal, QC
  • 🇺🇸United States tr Cascadia

    It seems that the type hint was deliberately chosen so that this code would work in D8, D9, and D10. Changing the type hint like you propose will break D8 compatibility. Update status is giving you a false positive in this case - it's not actually wrong.

    (And, if you are going to change the type hint in the @param then the constructor argument should also be type hinted. Right now it is not, again to allow this code to work with D8, D9, and D10.)

    See the commit at https://git.drupalcode.org/project/smtp/-/commit/a46b2f8a0d0a8e9cfcbeb85...

    Unfortunately, there is no issue associated with that commit, so no explanation of what was being done and why. I personally think it's a mistake to add and keep D8-specific workaround in the current branch, as D8 has been end-of-life for almost two years now. If D8 compatibility is to be maintained in the 8.x-1.x branch, then I would suggest a new branch for D9+ should be opened going forward so that some of the D8 legacy code can be dropped.

  • Status changed to Postponed over 1 year ago
  • 🇺🇸United States japerry KVUO

    Since the SMTP module is fairly simple, my personal preference is to maintain backward compatibility, if possible, to ease the ability for sites to upgrade. However, with D9 EOL coming soon, the next release of SMTP will probably be the last that supports Drupal 8.

Production build 0.71.5 2024