-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Description
Symfony version(s) affected: all
Description
Symfony used to namespace all generated ID but it's not the case for some services
- HttpClient:
symfony/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
Lines 2240 to 2249 in aea15bc
$container->register($name, ScopingHttpClient::class) ->setFactory([ScopingHttpClient::class, 'forBaseUri']) ->setArguments([new Reference($httpClientId), $baseUri, $scopeConfig]) ->addTag('http_client.client') ; } else { $container->register($name, ScopingHttpClient::class) ->setArguments([new Reference($httpClientId), [$scope => $scopeConfig], $scope]) ->addTag('http_client.client') ; symfony/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
Lines 2152 to 2156 in aea15bc
$container->register($name, TagAwareAdapter::class) ->addArgument(new Reference('.'.$name.'.inner')) ->addArgument(true !== $pool['tags'] ? new Reference($pool['tags']) : null) ->setPublic($pool['public']) ;
And maybe more
How to reproduce
framework:
http_client:
scoped_clients:
github:
base_uri: http://github.com
cache:
pools:
github: null
With the previous configuration, http_client replaces the cache definition (because http client configuration is processed after cache configuration).
>…goire/dev/labs/symfony/symfony-5.4(master *) bin/console debug:container github
// This service is a private alias for the service .debug.github
Information for Service ".debug.github"
=======================================
---------------- --------------------------------------------------
Option Value
---------------- --------------------------------------------------
Service ID .debug.github
Class Symfony\Component\HttpClient\TraceableHttpClient
And If I change the name of the github
http client:
>…goire/dev/labs/symfony/symfony-5.4(master *) bin/console debug:container github
Information for Service "github"
================================
An adapter that collects data about all cache calls.
---------------- --------------------------------------------------
Option Value
---------------- --------------------------------------------------
Service ID github
Class Symfony\Component\Cache\Adapter\TraceableAdapter
Possible Solution
We must namespace all services ID based on semantic configuration like we did in the past with messenger, workflow, etc
Additional context
This issue is a bit annoying with a different use case:
Once I declared a github
client, I'm no longer able to use bin/console debug:container github
to find all services that match github
because a github
service exists. Yes, I can still use | grep github
, but still :)