Doctrinebundle: Using the element "deprecated" is deprecated

Created on 25 Nov 2019  Â·  10Comments  Â·  Source: doctrine/DoctrineBundle

Got these 3 deprecation warnings recently:

Using the element "deprecated" is deprecated for the service "Symfony\Bridge\Doctrine\RegistryInterface" which is defined as an alias in ".../vendor/doctrine/doctrine-bundle/DependencyInjection/../Resources/config/dbal.xml". The XmlFileLoader will raise an exception in Symfony 4.0, instead of silently ignoring unsupported elements.

Using the element "deprecated" is deprecated for the service "Doctrine\Bundle\DoctrineBundle\Registry" which is defined as an alias in ".../vendor/doctrine/doctrine-bundle/DependencyInjection/../Resources/config/dbal.xml". The XmlFileLoader will raise an exception in Symfony 4.0, instead of silently ignoring unsupported elements.

Using the element "deprecated" is deprecated for the service "Doctrine\Common\Persistence\ObjectManager" which is defined as an alias in ".../vendor/doctrine/doctrine-bundle/DependencyInjection/../Resources/config/orm.xml". The XmlFileLoader will raise an exception in Symfony 4.0, instead of silently ignoring unsupported elements.

I'm using Symfony 3.4.35.

Question

All 10 comments

Possible solution: I removed the affected lines from the config files. Not sure how they got there, but the suggested replacements were already added so it felt a safe thing to do - and it worked well. Maybe it's just project specific thing, in that case ignore my report.

These were the lines I had to remove:

  1. /Resources/config/orm.xml
<service id="Doctrine\Common\Persistence\ObjectManager" alias="doctrine.orm.entity_manager" public="false">
    <deprecated>The "%alias_id%" service alias is deprecated, use `Doctrine\ORM\EntityManagerInterface` instead.</deprecated>
</service>
  1. /Resources/config/dbal.xml
<service id="Symfony\Bridge\Doctrine\RegistryInterface" alias="doctrine" public="false">
    <deprecated>The "%alias_id%" service alias is deprecated, use `Doctrine\Common\Persistence\ManagerRegistry` instead.</deprecated>
</service>
<service id="Doctrine\Bundle\DoctrineBundle\Registry" alias="doctrine" public="false">
    <deprecated>The "%alias_id%" service alias is deprecated, use `Doctrine\Common\Persistence\ManagerRegistry` instead.</deprecated>
</service>

These lines are not in the official repository, so I'm a bit confused how they got there.

This service is deprecated and remove on doctrine-bundle 2.0. You have this message because Symfony DependencyInjection not support the deprecated feature on 3.4

@blackWICKED please don’t modify vendor code. Instead, just ignore the deprecation as it is triggered by vendor code anyways. You can ignore it entirely in this case. Instead, whenever you’re using one of these services, stop using them.

When you upgrade to Symfony 4, the deprecation about the “deprecated” Attribute will be gone and you’ll instead receive a deprecation notice when you use one of the deprecated services.

Closing as there is no issue to be fixed here.

Well, we should avoid making our code throw deprecations though. A solution would be to alter definitions after the fact (in the DI extension) to mark them as deprecated only when Symfony supports it.

@stof that's a good point, thank you.

@maxhelias want to give this a shot since you took care of the original PR?

@alcaeus, yes I can take care of that, if ever the https://github.com/symfony/symfony/pull/34587 is not supported in Symfony

Good point. Let's wait until that is resolved. If that PR is not merged, we'll fix this here. Thanks for taking care of this! ❤️

well, my own vote on the symfony issue is that it should be rejected, given that it tries to allow using future features in 3.4, which does not make sense (marking aliases as deprecated is a Symfony 4.4+ feature).

FYI symfony/symfony#34587 has been rejected.

Thanks! @maxhelias care to open a PR to fix this in 1.12.2?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

soullivaneuh picture soullivaneuh  Â·  3Comments

garak picture garak  Â·  3Comments

Sjeijoet picture Sjeijoet  Â·  4Comments

peter-gribanov picture peter-gribanov  Â·  7Comments

spdionis picture spdionis  Â·  5Comments