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

Use the Persistence Proxy interface for checking ORM proxy objects #2715

Merged
merged 1 commit into from
Nov 25, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/References/Mapping/Event/Adapter/ODM.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Proxy\Proxy as ORMProxy;
use Doctrine\Persistence\Proxy as PersistenceProxy;
use Gedmo\Mapping\Event\Adapter\ODM as BaseAdapterODM;
use Gedmo\References\Mapping\Event\ReferencesAdapter;
use ProxyManager\Proxy\GhostObjectInterface;
Expand All @@ -32,7 +32,7 @@ public function getIdentifier($om, $object, $single = true)
}

if ($om instanceof EntityManagerInterface) {
if ($object instanceof ORMProxy) {
if ($object instanceof PersistenceProxy) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm wondering if relaxing this check deserves an entry in the changelog, since previous to this change only instances of Doctrine\ORM\Proxy\Proxy were admitted in this condition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd say this is more of an internal change to match the upstream API changes and not a deliberate feature change in this package. So not necessarily something that needs to be called out in a changelog entry.

$id = $om->getUnitOfWork()->getEntityIdentifier($object);
} else {
$meta = $om->getClassMetadata(get_class($object));
Expand Down
4 changes: 2 additions & 2 deletions src/References/Mapping/Event/Adapter/ORM.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Doctrine\ODM\MongoDB\DocumentManager as MongoDocumentManager;
use Doctrine\ODM\PHPCR\DocumentManager as PhpcrDocumentManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Proxy\Proxy as ORMProxy;
use Doctrine\Persistence\Proxy as PersistenceProxy;
use Gedmo\Exception\InvalidArgumentException;
use Gedmo\Mapping\Event\Adapter\ORM as BaseAdapterORM;
use Gedmo\References\Mapping\Event\ReferencesAdapter;
Expand Down Expand Up @@ -79,7 +79,7 @@ public function getSingleReference($om, $class, $identifier)

public function extractIdentifier($om, $object, $single = true)
{
if ($object instanceof ORMProxy) {
if ($object instanceof PersistenceProxy) {
$id = $om->getUnitOfWork()->getEntityIdentifier($object);
} else {
$meta = $om->getClassMetadata(get_class($object));
Expand Down
1 change: 0 additions & 1 deletion src/Tool/Wrapper/EntityWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use Doctrine\Common\Util\ClassUtils;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Proxy\Proxy;
use Doctrine\Persistence\Proxy as PersistenceProxy;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Tree/Entity/Repository/NestedTreeRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
namespace Gedmo\Tree\Entity\Repository;

use Doctrine\ORM\Exception\ORMException;
use Doctrine\ORM\Proxy\Proxy;
use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\Proxy;
use Gedmo\Exception\InvalidArgumentException;
use Gedmo\Exception\RuntimeException;
use Gedmo\Exception\UnexpectedValueException;
Expand Down
2 changes: 1 addition & 1 deletion src/Tree/Strategy/ORM/Nested.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Proxy\Proxy;
use Doctrine\Persistence\Proxy;
use Gedmo\Exception\InvalidArgumentException;
use Gedmo\Exception\UnexpectedValueException;
use Gedmo\Mapping\Event\AdapterInterface;
Expand Down
3 changes: 1 addition & 2 deletions tests/Gedmo/Timestampable/TimestampableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
namespace Gedmo\Tests\Timestampable;

use Doctrine\Common\EventManager;
use Doctrine\ORM\Proxy\Proxy;
use Gedmo\Tests\Mapping\Fixture\Xml\Timestampable;
use Doctrine\Persistence\Proxy;
use Gedmo\Tests\Timestampable\Fixture\Article;
use Gedmo\Tests\Timestampable\Fixture\Author;
use Gedmo\Tests\Timestampable\Fixture\Comment;
Expand Down
2 changes: 1 addition & 1 deletion tests/Gedmo/Translatable/Issue/Issue84Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Gedmo\Tests\Translatable\Issue;

use Doctrine\Common\EventManager;
use Doctrine\ORM\Proxy\Proxy;
use Doctrine\Persistence\Proxy;
use Gedmo\Tests\Tool\BaseTestCaseORM;
use Gedmo\Tests\Translatable\Fixture\Article;
use Gedmo\Translatable\Entity\Translation;
Expand Down
2 changes: 1 addition & 1 deletion tests/Gedmo/Wrapper/EntityWrapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Gedmo\Tests\Wrapper;

use Doctrine\Common\EventManager;
use Doctrine\ORM\Proxy\Proxy;
use Doctrine\Persistence\Proxy;
use Gedmo\Tests\Tool\BaseTestCaseORM;
use Gedmo\Tests\Wrapper\Fixture\Entity\Article;
use Gedmo\Tests\Wrapper\Fixture\Entity\Composite;
Expand Down