Problem/Motivation

Both the MIME Type Guesser service and the single implementation in core are marked as lazy:

  file.mime_type.guesser:
    class: Drupal\Core\File\MimeType\MimeTypeGuesser
    arguments: ['@stream_wrapper_manager']
    tags:
      - { name: service_collector, tag: mime_type_guesser, call: addMimeTypeGuesser }
    lazy: true
  file.mime_type.guesser.extension:
    class: Drupal\Core\File\MimeType\ExtensionMimeTypeGuesser
    arguments: ['@Drupal\Core\File\MimeType\MimeTypeMapInterface']
    tags:
      - { name: mime_type_guesser }
    lazy: true

Neither of these services are expensive to instantiate; the stream wrapper manager will be initialised anyway, and injecting the mime_type_guesser services via a tagger iterator will mean that the individual guessers will only be instantiated when needed (and if a guesser returns early, the later ones will not be needed at all).

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3579673

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

longwave created an issue. See original summary.

longwave changed the visibility of the branch 3579673-remove-lazy-declaration to hidden.

longwave’s picture

Status: Active » Needs review
smustgrave’s picture

Do these need to be deprecated?

longwave’s picture

I don't think anyone would be replacing these services directly, they would just add their own guesser, which works the same way as before.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Figured I’d ask. Okay to mark for you

  • catch committed b76ed4ab on 11.x
    task: #3579673 Remove lazy declaration and proxy class for MIME type...

  • catch committed 6e2b2070 on main
    task: #3579673 Remove lazy declaration and proxy class for MIME type...
catch’s picture

Version: main » 11.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to main and cherry-picked to 11.x, thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.