-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DependencyInjection][Bug] Cryptic service name with anonymous service as argument #26630
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Can you provide a reproducing case ? The service definition you gave above does not trigger this for me (are you sure it refers to this service ? this cryptic service id looks like one generated by the XMLFileLoader when defining a service without an id) |
@stof very sure, the error goes away if I change the ID attrib to class attrib. |
@dkarlovi Can you create a small example application that allows to reproduce the error? |
@xabbuh sure. |
Same error message with a malformed services.xml |
@mitridates A reproducible project would ease helping you. |
@xabbuh I haven't forgotten to do it, just waiting for the month to roll over to free up some time :) |
The XML loader creates randomly named services for anonymous declarations. Generating inlined definitions would fix the issue. I don't think there is any other way. |
@nicolas-grekas can't it use some better naming? Like Backtracking from this error would have been mission impossible. |
As inline definitions are now a first-class citizen in Symfony since 3.4 (rather than being things which are not guaranteed to work fine all the time), I think we might now refactor the XML loader to stop turning anonymous services into named ones (but it may have to wait for 4.2 due to the feature freeze depending on how we consider this refactoring). |
So, do you even need a test case then if the issue is understood? |
My case is not about of an anonymous service, only a wrong tag. I deleted the code but this example of services.xml throws the message as RuntimeException
|
Well, you still have an anonymous service (without any config here), as a @nicolas-grekas here is my proposal for a next version (probably 4.2 due to the feature freeze):
|
Good news, top level services with no "id" are forbidden since 4.0, see
Keeping inline services as inline definition should be doable, maybe for 4.1 also. |
I would, but haven't studied the DI component until now, could use some pointers |
Everything is in
|
Alright. I'll have some time tomorrow so will try it. |
@stof @nicolas-grekas, looking at this a bit, I mostly understand how it works currently, but this is a bit puzzling:
What does "inline definition" mean in this jargon? Do I create the |
Yes, we mean Definition instances instead of Reference |
… a dot (nicolas-grekas) This PR was merged into the 4.1-dev branch. Discussion ---------- [DI][FrameworkBundle] Hide service ids that start with a dot | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | #26630 | License | MIT | Doc PR | - Now that services are private by default, `debug:container` should display them by default. In fact, the public/private concept should not trigger a difference in visibility for this command. Instead, I propose to handle service ids that start with a dot as hidden services. PR should be ready. (For reference, I tried using a tag instead in #26891, but that doesn't work in practice when working on the implementation.) Commits ------- cea051e [DI][FrameworkBundle] Hide service ids that start with a dot
While working around #26629, I moved my service into a separate file, like this:
This produces a very cryptic error (note the name, also the class is not set, but the ID is):
The text was updated successfully, but these errors were encountered: