-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Labels
Description
Starting on a PR regarding another issue and I hooked up on of my applications to 2.8 instead of 2.6. For me this was 2 seconds to figure out it was caused by the old way of defining a factory service + method, but the error message might cause a lot of confusion for others. The message is thrown in the Definition class rather than the place where you expect it (Yaml Loader in this case).
The fix for this is to change your service definition:
# old
app.layout.menu.beta:
class: Knp\Menu\MenuItem
factory_service: app.layout.menu_builder
factory_method: createBetaMenu
tags:
- { name: knp_menu.menu, alias: beta }
# new
app.layout.menu.beta:
class: Knp\Menu\MenuItem
factory: [@app.layout.menu_builder, createBetaMenu]
tags:
- { name: knp_menu.menu, alias: beta }
The thing is that the error message below does not clearly reflect that. I don't think it's desired to put this information in the message below, but maybe someone has a nice idea where to put it instead.
Deprecated: The Symfony\Component\DependencyInjection\Definition::setFactoryMethod method is deprecated since version 2.6 and will be removed in 3.0. Use Definition::setFactory() instead. in /home/ivanderberg/projects/symfony/src/Symfony/Component/DependencyInjection/Definition.php on line 137
ddimitrioglo, stfalcon, jaredKreate, fsmeier and Crovitche-1623
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
xabbuh commentedon May 19, 2015
To get a more sensible deprecation message, we will have to trigger them in the loader classes. However, this would mean that one one get two messages, one from the loader and one from the
Definition
class.I see two solutions to get rid of the double message:
setFactoryClass()
,setFactoryService()
andsetFactoryMethod()
and let them callsetFactory()
instead regardless of how the user configured the factory. Will that solution have any downsides?Tobion commentedon May 19, 2015
Just add to the deprecation message in the Definition that it could also be caused by using
factory_service
andfactory_method
in configuration file.linaori commentedon May 19, 2015
Another question related to this though, I have fixed all my application usages, but composer is still complaining. I suspect this is coming from a third-party bundle, but I am not sure which or where just yet.
The problem is that I can't suppress those warnings in composer and it will cause a deployment failure on the
cache:warmup
. Any tips on that issue?xabbuh commentedon May 19, 2015
@Tobion Though you would still not know which file actually causes the issue. Given that the warning can also be triggered by a third-party bundle, this could become hard to debug imho.
Tobion commentedon May 19, 2015
@xabbuh true
stof commentedon May 20, 2015
@xabbuh calling
setFactory
is not an option, because it would force to have a service definition defining the whole factory at once, while the old syntax allows that (think about a service overwriting only part of the factory compared to the parent)minor #14720 [2.7][DI] Definition deprecation notice includes the par…
eXtreme commentedon May 24, 2015
I've had similar problems as @iltar with composer/warmup spamming with deprecations - afair it was caused by sonata admin dependency and as a quick fix I placed
error_reporting(E_ALL & ~E_USER_DEPRECATED & ~E_DEPRECATED);
in the constructor of my kernel.nicolas-grekas commentedon May 29, 2015
Having better error messages would be great, even in 2.7.x releases IMO. I wouldn’t mind the duplicate too much.
xabbuh commentedon May 31, 2015
see #14798
gnutix commentedon May 31, 2015
Is there a way to filter the deprecation messages that comes from the application code (
app/
&src/
) and not 3rd-party code (vendor/
) ?minor #14798 [DependencyInjection] provide better error message when …