-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[6.2] Reference to abstract service with invalidBehavior:IGNORE_ON_INVALID_REFERENCE still produces error #48411
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
Current work around is before I add services to the service locator, I filter them like this: /**
* This is needed because Symfony 6.2 adds excluded services ALSO to the container, but then
* tagged with `container.excluded`. The Reference invalidBehavior: IGNORE_ON_INVALID_REFERENCE is ignored.
* Waiting for them to fix it, until then, we filter out any services that are either abstract or excluded.
*
* @see https://github.com/symfony/symfony/issues/48411
*
* @param array<string, Reference> $references
*
* @return array<string, Reference>
*/
private function filterInvalidReferences(ContainerBuilder $container, array $references) : array
{
return array_filter($references, function (Reference $reference) use ($container) {
if ($container->hasDefinition((string) $reference) === false) {
return false;
}
$definition = $container->getDefinition((string) $reference);
if ($definition->isAbstract()) {
return false;
}
if ($definition->hasTag('container.excluded')) {
return false;
}
return true;
});
} |
nicolas-grekas
added a commit
that referenced
this issue
Dec 5, 2022
…excluded services when allowed (nicolas-grekas) This PR was merged into the 6.2 branch. Discussion ---------- [DependencyInjection] Remove refs that point to container.excluded services when allowed | Q | A | ------------- | --- | Branch? | 6.2 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #48411 | License | MIT | Doc PR | - Commits ------- 2e9fdf0 [DependencyInjection] Remove refs that point to container.excluded services when allowed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Symfony version(s) affected
6.2.0
Description
After upgrading to 6.2.0 I noticed that some of my service locators broke.
How to reproduce
I was adding some typed arguments of a method (in a compiler pass) to an array like this:
I was using
ContainerInterface::IGNORE_ON_INVALID_REFERENCE
to automatically filter out invalid services. This used to work fine in 6.1.But in 6.2.0 I get this error:
Possible Solution
I think
CheckReferenceValidityPass
should not report an error when theReference
hasContainerInterface::IGNORE_ON_INVALID_REFERENCE
.Additional Context
It's related to:
The text was updated successfully, but these errors were encountered: