EntityManagerInterface extends deprecated Doctrine\Common\Persistence\ObjectManager #6367

Closed
opened 2026-01-22 15:31:54 +01:00 by admin · 3 comments
Owner

Originally created by @vanoostrum on GitHub (Dec 16, 2019).

Bug Report

Q A
BC Break no
Version 2.7.0

Summary

When the classloader loads Doctrine\ORM\EntityManagerInterface a deprecation warning is triggered stating: "The Doctrine\Common\Persistence\ObjectManager class is deprecated since doctrine/persistence 1.3 and will be removed in 2.0. Use \Doctrine\Persistence\ObjectManager instead."

Current behavior

Doctrine ORM 2.7.0 requires the library doctrine/persistence: ^1.2 in its composer.json. This will resolve to doctrine/persistence 1.3.3 being installed.
In this version Doctrine\Common\Persistence\ObjectManager is deprecated in favor of \Doctrine\Persistence\ObjectManager.

Doctrine\ORM\EntityManagerInterface however still extends Doctrine\Common\Persistence\ObjectManager. This results in a deprecation warning when the class is loaded.

Note: Deprecated code is potentially being used in other places in the Doctrine\ORM Library. This should be fixed as soon as possible.

How to reproduce

  1. Make sure composer will install Doctrine ORM version 2.7.0, without specifying a specific version of Doctrine\Persistence. Composer should install Doctrine Persistence version 1.3.3.
  2. Use the class Doctrine\ORM\EntityManagerInterface to trigger the classloader to load the class.
  3. Notice the deprecation warning: "The Doctrine\Common\Persistence\ObjectManager class is deprecated since doctrine/persistence 1.3 and will be removed in 2.0. Use \Doctrine\Persistence\ObjectManager instead."

Expected behavior

The class should be loaded with no deprecation warning.

Originally created by @vanoostrum on GitHub (Dec 16, 2019). ### Bug Report | Q | A |------------ | ------ | BC Break | no | Version | 2.7.0 #### Summary <!-- Provide a summary describing the problem you are experiencing. --> When the classloader loads `Doctrine\ORM\EntityManagerInterface` a deprecation warning is triggered stating: "The Doctrine\Common\Persistence\ObjectManager class is deprecated since doctrine/persistence 1.3 and will be removed in 2.0. Use \Doctrine\Persistence\ObjectManager instead." #### Current behavior Doctrine ORM 2.7.0 requires the library doctrine/persistence: ^1.2 in its composer.json. This will resolve to doctrine/persistence 1.3.3 being installed. In this version `Doctrine\Common\Persistence\ObjectManager` is deprecated in favor of `\Doctrine\Persistence\ObjectManager`. `Doctrine\ORM\EntityManagerInterface` however still extends `Doctrine\Common\Persistence\ObjectManager`. This results in a deprecation warning when the class is loaded. **Note**: Deprecated code is potentially being used in other places in the Doctrine\ORM Library. This should be fixed as soon as possible. #### How to reproduce 1. Make sure composer will install Doctrine ORM version 2.7.0, without specifying a specific version of Doctrine\Persistence. Composer should install Doctrine Persistence version 1.3.3. 2. Use the class `Doctrine\ORM\EntityManagerInterface` to trigger the classloader to load the class. 3. Notice the deprecation warning: "The Doctrine\Common\Persistence\ObjectManager class is deprecated since doctrine/persistence 1.3 and will be removed in 2.0. Use \Doctrine\Persistence\ObjectManager instead." #### Expected behavior The class should be loaded with no deprecation warning.
admin added the Deprecation label 2026-01-22 15:31:54 +01:00
admin closed this issue 2026-01-22 15:31:54 +01:00
Author
Owner

@lcobucci commented on GitHub (Dec 16, 2019):

We consider deprecation messages as warnings in the ORM and to solve these ones we'd have to bump doctrine/persistence requirement up to ^1.3.3 (v2.7.x depends on ^1.2) and we don't perform this operation in patch releases (only minor).

We'll be addressing this for ORM v2.8 (#7953 already handles this).

@lcobucci commented on GitHub (Dec 16, 2019): We consider deprecation messages as warnings in the ORM and to solve these ones we'd have to bump `doctrine/persistence` requirement up to `^1.3.3` (`v2.7.x` depends on `^1.2`) and we don't perform this operation in patch releases (only minor). We'll be addressing this for ORM v2.8 (#7953 already handles this).
Author
Owner

@mhujer commented on GitHub (Dec 20, 2019):

For those interested, here is the related PR in Doctrine ORM repository https://github.com/doctrine/orm/pull/7953

@mhujer commented on GitHub (Dec 20, 2019): For those interested, here is the related PR in Doctrine ORM repository https://github.com/doctrine/orm/pull/7953
Author
Owner

@vanoostrum commented on GitHub (Jan 7, 2020):

@lcobucci Thanks for the explanation. It's a clear argument. We will be awaiting the next version. Until then we can avoid the deprecation warning by overriding the version in our own composer.json files.

I will close the issue because the deprecation will be resolved in a future release.

@vanoostrum commented on GitHub (Jan 7, 2020): @lcobucci Thanks for the explanation. It's a clear argument. We will be awaiting the next version. Until then we can avoid the deprecation warning by overriding the version in our own composer.json files. I will close the issue because the deprecation will be resolved in a future release.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6367