Skip to content

[DependencyInjection] Resolve parameters in tag arguments #37243

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

Merged
merged 1 commit into from
Jul 31, 2020

Conversation

rpkamp
Copy link
Contributor

@rpkamp rpkamp commented Jun 12, 2020

Q A
Branch? master
Bug fix? no
New feature? yes
Deprecations? no
Tickets Fix #35337
License MIT
Doc PR None, yet, will follow if this is accepted

Arguably this could be a BC break if people are actively relying on parameters not being resolved in tag parameters, although I can't come up with a sensible use case for that scenario.

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Jun 30, 2020

I'm fine with the implementation but I'm not sure I understand the use case (I just re-read the linked issue but that's doesn't help to get when this is useful). Could you please elaborate a bit on this aspect?

(rebase needed btw)

@rpkamp
Copy link
Contributor Author

rpkamp commented Jun 30, 2020

We have a multi-tenant setup, where each of the tenants have their own URL and those URLs are used internally to identify them. Since we have multiple environments (dev, staging, prod) these URLs change per environment, so we're storing those in parameters and override them in different environments (eg dev.symfony.com and www.symfony.com).

What we want to do is be able to tag certain services, like CRM clients, with the URL of the tenant so that we can use a locator to get the CRM client of the current client, based on the current URL.

For that we need Symfony to be able to process parameters in tag values.

So right now we have a class that takes a ServiceLocator and the ParameterBag as arguments and then does the replacement internally, and that works, but it's rather ugly.

As an aside, we don't use DotEnv, just plain old parameters.

@rpkamp rpkamp force-pushed the parameters-tag-arguments branch from d352ff0 to 24d4e79 Compare June 30, 2020 17:51
@rpkamp
Copy link
Contributor Author

rpkamp commented Jun 30, 2020

Rebase onto master done @nicolas-grekas

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the info. Works on my side.

@fabpot fabpot force-pushed the parameters-tag-arguments branch from 24d4e79 to 3dba1fe Compare July 31, 2020 07:38
@fabpot
Copy link
Member

fabpot commented Jul 31, 2020

Thank you @rpkamp.

@stof
Copy link
Member

stof commented Jul 31, 2020

This is a BC break, because it now requires escaping % in tag arguments.

@stof
Copy link
Member

stof commented Jul 31, 2020

And it is a BC break without any easy upgrade path for the ecosystem (escaping the % would then break things with older versions of Symfony which would not unescape things).

And this implementation is also built in a way which might require the whole ecosystem to adapt: parameters are resolved when using findTaggedServices, but would require manual resolution if you use other ways to access the attributes (getTags on the definition for instance)

@nicolas-grekas
Copy link
Member

About the potential BC break, I think we can assume nobody is using a % there.
About the implementation, this could be resolved in a compiler pass I agree.
@rpkamp could you please have a look?

@nicolas-grekas
Copy link
Member

Or should this be opt-in, via a new argument to the method?

@rpkamp
Copy link
Contributor Author

rpkamp commented Aug 10, 2020

I'm not sure my niche problem warrants so much effort to get it into Symfony - energy vs. gain feels off.

Could you maybe revert this MR @nicolas-grekas and I can go back to the drawing board? Might end up writing a simple compiler pass inside our project instead. If that works out nicely I might create a new PR with that, which can then be optionally enabled if people wanted to.

@nicolas-grekas
Copy link
Member

Ok to revert of course. Can you open a PR please ? I'm afk.

@rpkamp
Copy link
Contributor Author

rpkamp commented Aug 10, 2020

Ok to revert of course. Can you open a PR please ? I'm afk.

Done, #37793

fabpot added a commit that referenced this pull request Aug 10, 2020
…g arguments" (rpkamp)

This PR was merged into the 5.2-dev branch.

Discussion
----------

Revert "[DependencyInjection] Resolve parameters in tag arguments"

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | #35337
| License       | MIT
| Doc PR        | N/A

Revert of earlier PR, see discussion #37243

Commits
-------

9731451 Revert "[DependencyInjection] Resolve parameters in tag arguments"
@nicolas-grekas nicolas-grekas modified the milestones: next, 5.2 Oct 5, 2020
@fabpot fabpot mentioned this pull request Oct 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DependencyInjection] Parameters are not expanded in indexed !tagged_locator
5 participants