Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[FrameworkExtension] Symfony/mercure-notifier does not check if Mercure bundle is enabled. #48305

Copy link
Copy link
Closed
@jorge-ruukfy

Description

@jorge-ruukfy
Issue body actions

Symfony version(s) affected

6.0.x

Description

Got three parallel applications, using same composer definition.
Only one of them make use of symfony notifier

Having installed symfony/mercure-notifier makes the other applications fail with:

The service "notifier.transport_factory.mercure" has a dependency on a non-existent service "Symfony\Component\Mercure\HubRegistry".

https://github.com/symfony/framework-bundle/blob/6.1/DependencyInjection/FrameworkExtension.php#L2599-L2603

Checks the existence of symfony/mercure-notifier and symfony/mercure-bundle but NOT that symfony/mercure-bundle is enabled.

The only existence of the packages does not have to mean that are enabled for that application.

How to reproduce

  1. Make two parallel applications using the same composer definition.
  2. Install notifier and mercure-notifier on one of them.
  3. The other application will fail to boot as HubRegistry has to be configured

Possible Solution

  • BEST: FrameworkExtension should delegate on symfony/mercure-notifier the dependency injection upon Mercure-bundle is enabled
  • AFFORDABLE: FrameworkExtension could check if Mercure-Bundle is enabled.
if (ContainerBuilder::willBeAvailable('symfony/mercure-notifier', MercureTransportFactory::class, $parentPackages)
            && ContainerBuilder::willBeAvailable('symfony/mercure-bundle', MercureBundle::class, $parentPackages)
            && array_key_exists('MercureBundle',$container->getParameter('kernel.bundles')))
  • SLOPPY: notifier.transport_factory.mercure could have a nullable HubRegistry parameter, doing nothing

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.