Problem/Motivation

With persistent app servers such as FrankenPHP worker mode, Symfony's default MIME registry stays alive and handles multiple requests. MimeTypeGuesser::registerWithSymfonyGuesser() registers Drupal's guesser directly, retaining it and its dependencies even after the container is discarded. Container references reachable through those dependencies prevent garbage collection until the registry is replaced.

Steps to reproduce

  1. Create a container with a file.mime_type.guesser test double that holds a reference to that container.
  2. Register it using the helper above and create a weak reference to the container.
  3. Unset local container and guesser references, then call gc_collect_cycles().
  4. The weak reference still returns the container; it should return NULL.

Proposed resolution

Register an adapter holding a weak reference to Drupal's guesser. Delegate while the guesser exists; report unsupported after collection so Symfony uses its remaining guessers.

User interface changes

None.

API changes

None.

Data model changes

None.

AI disclosure: I used AI to help prepare the IS and MR (Astra and Opus 5.5).

Issue fork drupal-3626372

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

ptmkenny created an issue. See original summary.

ptmkenny’s picture

Status: Active » Needs work

I'm adding an MR, but I'm not sure this is the right approach, so I set it to Draft and I'm setting this issue to "Needs work".