-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[DependencyInjection][FrameworkBundle] fix BC break when dumping container for build/lint commands #62586
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
Conversation
|
Failing tests seem unrelated to me |
| $container->setDefinitions($dumpedContainer->getDefinitions()); | ||
| $container->setAliases($dumpedContainer->getAliases()); | ||
| $container->__construct($dumpedContainer->getParameterBag()); | ||
| $container->setParameterBag($dumpedContainer->getParameterBag()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather not add a new method. Can't we use a foreach instead, copying all parameters one by one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how a foreach would work? Would you use reflections instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't we iterate over the parameters from the bag of the dumped container and call set() on the bag from the empty one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, that could work as well! I'll investigate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed in 02551f3. This would fail if we have a FrozenParameterBag, but I don't think that is ever the case as long as the container is not compiled.
…ainer for build/lint commands
02551f3 to
843fbca
Compare
|
Thank you @aschempp. |
#60597 introduced a BC break in that it assumes the
ContainerBuilderconstructor accepts the parameter bag as its first argument. However, in our application, we have a custom version of theContainerBuilder.Since the container is already built at this state, I understand that calling
__construct()again is just a hack to re-set the parameter bag. A direct setter function for this case should fix the issue.PS:
Kernel::buildContainermust always return an instance ofContainerBuilder, so the setter method must always be there (our class inherits from it as well).Links:
ContainerBuilderindevcontao/contao#9058ContainerBuilderhttps://github.com/contao/manager-plugin/blob/main/src/Config/ContainerBuilder.php