Skip to content

Commit

Permalink
[GH-8383] deprecate notify change tracking policy (#8473)
Browse files Browse the repository at this point in the history
* [GH-8383] Deprecate notify change tracking policy.

* [GH-8383] Add warning to documentation about notify change tracking policy deprecation.
  • Loading branch information
beberlei authored Feb 13, 2021
1 parent 6fe388a commit e2e59e9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ code should look like. We will implement it on a
`Layer Supertype <http://martinfowler.com/eaaCatalog/layerSupertype.html>`_
for all our domain objects.

.. warning::

The notify change tracking policy is deprecated and will be removed in ORM 3.0.
(`Details <https://github.com/doctrine/orm/issues/8383>`_)

Implementing NotifyPropertyChanged
----------------------------------

Expand Down
5 changes: 5 additions & 0 deletions docs/en/reference/change-tracking-policies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ This policy can be configured as follows:
Notify
~~~~~~

.. warning::

The notify change tracking policy is deprecated and will be removed in ORM 3.0.
(`Details <https://github.com/doctrine/orm/issues/8383>`_)

This policy is based on the assumption that the entities notify
interested listeners of changes to their properties. For that
purpose, a class that wants to use this policy needs to implement
Expand Down
10 changes: 10 additions & 0 deletions lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Doctrine\Common\EventManager;
use Doctrine\DBAL\Platforms;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\Deprecations\Deprecation;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Event\LoadClassMetadataEventArgs;
use Doctrine\ORM\Event\OnClassMetadataNotFoundEventArgs;
Expand Down Expand Up @@ -239,6 +240,15 @@ protected function doLoadMetadata($class, $parent, $rootEntityFound, array $nonS
$this->evm->dispatchEvent(Events::loadClassMetadata, $eventArgs);
}

if ($class->changeTrackingPolicy === ClassMetadataInfo::CHANGETRACKING_NOTIFY) {
Deprecation::trigger(
'doctrine/orm',
'https://github.com/doctrine/orm/issues/8383',
'NOTIFY Change Tracking policy used in "%s" is deprecated, use deferred explicit instead.',
$class->name
);
}

$this->validateRuntimeMetadata($class, $parent);
}

Expand Down
6 changes: 6 additions & 0 deletions tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Doctrine\Tests\ORM\Functional;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Deprecations\PHPUnit\VerifyDeprecations;
use Doctrine\Persistence\NotifyPropertyChanged;
use Doctrine\Persistence\PropertyChangedListener;
use Doctrine\Tests\OrmFunctionalTestCase;
Expand All @@ -17,9 +18,14 @@
*/
class NotifyPolicyTest extends OrmFunctionalTestCase
{
use VerifyDeprecations;

protected function setUp(): void
{
parent::setUp();

$this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/issues/8383');

try {
$this->_schemaTool->createSchema(
[
Expand Down

0 comments on commit e2e59e9

Please sign in to comment.