-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Upgrade to 5.4 failed: Invalid service the class is not set. #44342
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
Hi @gjuric! Can you provide a minimal reproducer that shows this error? That'll help someone (or you 😉) to debug this error. |
Sure, I will take a look at it tomorrow, I've tried setting up the skeleton app from the linked documentation but it installs v6, after manually downgrading to 5.4 I wasn't able to install the maker bundle because of dependencies and downgrading to 5.3 to get the maker bundle broke the skeleton app because of a missing method in the MicroKernelTrait so I need to take care of that first :) |
Hi, at our company we're experiencing the same :) thanks @gjuric for the minimal reproducer :) |
I am having trouble generating a minimal reproducer since there using a factory to get the Entity Repository works :( If I downgrade the
Couple of things to add:
|
I've managed to create a reproducer and I've updated the issue with additional context. |
Thanks a lot @gjuric! The lines you mention in the PR description haven't been changed for years. However, if I use Symfony 5.3 I get Would be cool if someone can dig deeper into this :) |
Looks like a bug on 4.4 here symfony/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php Line 137 in 382cde2
$class can be null, even with $required = false , getConstructor() ends up throwing.
symfony/src/Symfony/Component/DependencyInjection/Compiler/AttributeAutoconfigurationPass.php Line 102 in a12336a
I guess if there is no class in the definition with |
Actually, let's catch the exception, that's what we do everywhere else, I'll submit a patch. |
…rs in AttributeAutoconfigurationPass if we can't get the constructor reflector (fancyweb) This PR was merged into the 5.4 branch. Discussion ---------- [DependencyInjection] Skip parameter attribute configurators in AttributeAutoconfigurationPass if we can't get the constructor reflector | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | #44342 | License | MIT | Doc PR | - `$required = false` on `getConstructor()` doesn't mean it doesn't throw. I have looked at our other usages, and we catch the exception when we want to ignore it. I'd still like to return null when the definition class is null though (on 4.4). Commits ------- b2fe0e0 [DependencyInjection] Skip parameter attribute configurators in AttributeA 8000 utoconfigurationPass if we can't get the constructor reflector
@nicolas-grekas @fancyweb any chance of 5.4.1 being released with this fix in it? |
Patch releases are usually done regularly once a month. |
…ecursivePass (fancyweb) This PR was merged into the 4.4 branch. Discussion ---------- [DependencyInjection] Resolve ChildDefinition in AbstractRecursivePass | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | #44342 | License | MIT | Doc PR | - At least `AttributeAutoconfigurationPass` (5.4 new pass) relies on `AbstractRecursivePass` and is executed before `ResolveChildDefinitionsPass` so child definitions are not necessary resolved in `AbstractRecursivePass`. Doing it on 4.4 to have the same behavior on all maintained branches. It fixes #44342 in a better way because the final class of the factory can be resolved. Commits ------- acbee81 [DependencyInjection] Resolve ChildDefinition in AbstractRecursivePass
Uh oh!
There was an error while loading. Please reload this page.
Symfony version(s) affected
5.4.0
Description
I've just tried updating from latest 5.3.11 to 5.4.0 and after the packages have been updated the container can not be built with complaints about my custom repositories not having a class set.
How to reproduce
I've created a reproducer here: https://github.com/gjuric/symfony_5_4_bug/
The repositories are defined like this:
I've tried adding the
class
attribute to the<service>
tag but it doesn't help.Possible Solution
No response
Additional Context
When compiler is trying to build this server it sees it has a factory and tries to fetch the Class here:
symfony/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php
Line 132 in a12336a
$this->container->findDefinition((string) $class)
returns and instance ofSymfony\Component\DependencyInjection\ChildDefinition
whereparent
is set todoctrine.orm.entity_manager.abstract
and theclass
property is set tonull
. This null is then passed toreturn $this->getReflectionMethod(new Definition($class), $method);
where it is of course not possible to build a definition since$class
isnull
.The text was updated successfully, but these errors were encountered: