Reputation: 18765
I have just updated a Symfony 2.7 project to 2.8. Now I am preparing to update the project to Symfony 3. The Profile shows, that a great number (over 1500) of deprecated methods/classes are used on each request.
Of course I would like to solve these issues. However as far as I can tell, the deprecated code is uses by Symfony itself and not by my own code.
Here is an example:
ConfigCache::__toString() is deprecated since version 2.7 and will be removed in 3.0. Use the getPath() method instead. (4 times)
ConfigCache::__toString() (called from AllowedMethodsRouterLoader.php at line 51)
AllowedMethodsRouterLoader::getAllowedMethods() (called from AllowedMethodsRouterLoader.php at line 51)
AllowedMethodsRouterLoader::getAllowedMethods() (called from AllowedMethodsListener.php at line 41)
AllowedMethodsListener::onKernelResponse()
call_user_func() (called from WrappedListener.php at line 61)
WrappedListener::__invoke()
call_user_func() (called from EventDispatcher.php at line 184)
...a lot more Twig calls...
Twig_Template::displayWithErrorHandling() (called from Template.php at line 347)
Twig_Template::display() (called from Template.php at line 358)
Twig_Template::render() (called from TwigEngine.php at line 50)
TwigEngine::render() (called from TwigEngine.php at line 72)
TwigEngine::render() (called from TwigEngine.php at line 97)
TwigEngine::renderResponse() (called from Controller.php at line 185)
Controller::render() (called from RegistrationController.php at line 71)
RegistrationController::registerAction()
call_user_func_array() (called from HttpKernel.php at line 144)
HttpKernel::handleRaw() (called from HttpKernel.php at line 64)
HttpKernel::handle() (called from ContainerAwareHttpKernel.php at line 69)
ContainerAwareHttpKernel::handle() (called from Kernel.php at line 185)
Kernel::handle() (called from app_dev.php at line 37)
Of course my own code also involved in this call stack: The RegistrationController
handled the request and used a Twig
template to render the page. However the code that uses the deprecated ConfigCache::__toString()
method is from within the AllowedMethodsRouterLoader
class, which is part of Symfony.
Is there anything my code can do to avoid this deprecated code?
I am quite surprised, that Symfony code itself uses deprecated code. It there any way to filter out these messages and only get notified about deprecations in my own code?
Upvotes: 0
Views: 1778
Reputation: 679
You may be interested in the Deprecation Detector from Sensio Labs ( creator of Symfony ).
Deprecation Detector on Github
I used it quite a bit removing deprecated classes/methods in 2.8 preparing to move to 3.0. Was a great time saver. Highly recommended.
I'd also recommend Symfony Upgrade Fixer to save even more time especially regarding form classes.
Upvotes: 1
Reputation: 35169
It's running deprecated code - within the Symfony codebase, but it is being called from Twig. Since Twig is a first-class part of Symfony, but not a a formal part of the Symfony project, it has it's own releases. A more up to date version of Twig, as well as other libraries, will have removed the use of deprecated code, or at least done something towards improving the status.
So, large part of updating a Symfony framework based project, is also updating the rest of the libraries that are also being used. Just updating the "symfony/symfony"
line in composer.json is not enough.
Upvotes: 1