Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deprecation warnings for 2.7.x #7901

Merged
merged 4 commits into from Nov 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
98 changes: 98 additions & 0 deletions UPGRADE.md
@@ -1,5 +1,103 @@
# Upgrade to 2.7

## Deprecated code generators and related console commands

These console commands have been deprecated:

* `orm:convert-mapping`
* `orm:generate:entities`
* `orm:generate-repositories`

These classes have been deprecated:

* `Doctrine\ORM\Tools\EntityGenerator`
* `Doctrine\ORM\Tools\EntityRepositoryGenerator`

Whole Doctrine\ORM\Tools\Export namespace with all its members have been deprecated as well.

## Deprecated `Doctrine\ORM\Proxy\Proxy` marker interface

Proxy objects in Doctrine 3.0 will no longer implement `Doctrine\ORM\Proxy\Proxy` nor
`Doctrine\Common\Persistence\Proxy`: instead, they implement
`ProxyManager\Proxy\GhostObjectInterface`.

These related classes have been deprecated:

* `Doctrine\ORM\Proxy\ProxyFactory`
* `Doctrine\ORM\Proxy\Autoloader` - we suggest using the composer autoloader instead
lcobucci marked this conversation as resolved.
Show resolved Hide resolved

These methods have been deprecated:

* `Doctrine\ORM\Configuration#getAutoGenerateProxyClasses()`
* `Doctrine\ORM\Configuration#getProxyDir()`
* `Doctrine\ORM\Configuration#getProxyNamespace()`

## Deprecated `Doctrine\ORM\Version`

The `Doctrine\ORM\Version` class is now deprecated and will be removed in Doctrine 3.0:
please refrain from checking the ORM version at runtime or use
[Ocramius/PackageVersions](https://github.com/Ocramius/PackageVersions/).
lcobucci marked this conversation as resolved.
Show resolved Hide resolved

## Deprecated `EntityManager#merge()` and `EntityManager#detach()` methods

Merge and detach semantics were a poor fit for the PHP "share-nothing" architecture.
In addition to that, merging/detaching caused multiple issues with data integrity
in the managed entity graph, which was constantly spawning more edge-case bugs/scenarios.

The following API methods were therefore deprecated:

* `EntityManager#merge()`
* `EntityManager#detach()`
* `UnitOfWork#merge()`
* `UnitOfWork#detach()`

Users are encouraged to migrate `EntityManager#detach()` calls to `EntityManager#clear()`.

In order to maintain performance on batch processing jobs, it is endorsed to enable
the second level cache (http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/second-level-cache.html)
on entities that are frequently reused across multiple `EntityManager#clear()` calls.

An alternative to `EntityManager#merge()` will not be provided by ORM 3.0, since the merging
semantics should be part of the business domain rather than the persistence domain of an
application. If your application relies heavily on CRUD-alike interactions and/or `PATCH`
restful operations, you should look at alternatives such as [JMSSerializer](https://github.com/schmittjoh/serializer).

## Extending `EntityManager` is deprecated

Final keyword will be added to the `EntityManager::class` in Doctrine 3.0 in order to ensure that EntityManager
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, DoctrineBundle generates a proxy class (using ocramius/proxy-manager) for the entity manager, to allow resetting the entity manager (allowing to inject the entity manager in other services without having to kill the whole PHP process to rebuild all services in case an error occurs in the ORM). Will Doctrine ORM 3.0 allow reopening an entity manager instance (which of course involve it will be cleared) ? If no, this change means that using the EntityManager in a service used by a long-running process (a RabbitMQ consumer for instance) won't be possible anymore, which is quite impactful.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The architecture in v3 is quite different. The design we have been discussing is that each transaction will use a different UoW instance. This promotes better isolation and removes the need for em to be closed (in theory). There are still things to be addressed on this but that's the gist.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, if an em does not get closed on failure, then that's fine.

is not used as valid extension point. Valid extension point should be EntityManagerInterface.

## Deprecated `EntityManager#flush($entity)` and `EntityManager#flush($entities)`

If your code relies on single entity flushing optimisations via
`EntityManager#flush($entity)`, the signature has been changed to
`EntityManager#flush()`.

Said API was affected by multiple data integrity bugs due to the fact
that change tracking was being restricted upon a subset of the managed
entities. The ORM cannot support committing subsets of the managed
entities while also guaranteeing data integrity, therefore this
utility was removed.

The `flush()` semantics will remain the same, but the change tracking will be performed
on all entities managed by the unit of work, and not just on the provided
`$entity` or `$entities`, as the parameter is now completely ignored.

The same applies to `UnitOfWork#commit($entity)`, which will simply be
`UnitOfWork#commit()`.

If you would still like to perform batching operations over small `UnitOfWork`
instances, it is suggested to follow these paths instead:

* eagerly use `EntityManager#clear()` in conjunction with a specific second level
cache configuration (see http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/second-level-cache.html)
* use an explicit change tracking policy (see http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/change-tracking-policies.html)

## Deprecated `YAML` mapping drivers.

If your code relies on `YamlDriver` or `SimpleYamlDriver`, you **MUST** change to
annotation or XML drivers instead.

## Deprecated: `Doctrine\ORM\EntityManagerInterface#copy()`

Method `Doctrine\ORM\EntityManagerInterface#copy()` never got its implementation and is deprecated.
Expand Down