php-http/HttplugBundle

The httplug.collector.twig.http_message service is deprecated since version 1.17

ruudk opened this issue · 5 comments

ruudk commented

On my project I upgraded to httplug-bundle dev-master and am getting:

The httplug.collector.twig.http_message service is deprecated since version 1.17 and will be removed in 2.0. Use "@Httplug/http_message.html.twig" template instead.

while running my tests with Symfony's deprecation helper.

I checked if httplug.collector.twig.http_message was used somewhere, but it is not.

How can I fix this deprecation?

I think the error is produced by Symfony while it compiles the container.

dbu commented

that message comes from https://github.com/php-http/HttplugBundle/blob/master/src/Resources/config/data-collector.xml#L27 and with blame, we find #355

did you customize anything in your application? the http_message service is only kept around for BC, but should not be used by anything in the bundle itself

ruudk commented

I think this is happening because it’s a tagged service. Therefore, the Twig extension will load it, and trigger the deprecation?

ruudk commented

Created a Symfony 4.4 demo app that shows the deprecation: https://github.com/ruudk/httplug-bundle-deprecated-error-poc/tree/master

It's caused by the fact that Twig automatically loads the extension because it's a tagged service. When Twig instanciates, it constructs the deprecated extension, that triggers the deprecation.

Solution: Remove the <deprecated> tag from the service. WDYT?

dbu commented

thanks for the demo app, that was useful to quickly play with the thing! indeed removing the deprecated mark in the service seems like the right fix - we do trigger deprecation in the php code if it is actually used.

ruudk commented

Thanks @dbu !