diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 8b449bdb4..b12bc1de5 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -2232,8 +2232,6 @@ class UnitOfWork implements PropertyChangedListener $entitiesToCascade = array(); - // We need to load all related entities beforehand so that lazy collection loading doesn't - // reload entities after they have been removed (bug DDC-2775) foreach ($associationMappings as $assoc) { if ($entity instanceof Proxy && !$entity->__isInitialized__) { $entity->__load(); diff --git a/tests/Doctrine/Tests/Models/DDC2775/AdminRole.php b/tests/Doctrine/Tests/Models/DDC2775/AdminRole.php deleted file mode 100644 index d40bb625a..000000000 --- a/tests/Doctrine/Tests/Models/DDC2775/AdminRole.php +++ /dev/null @@ -1,8 +0,0 @@ -authorizations[] = $authorization; - $authorization->role = $this; - } -} diff --git a/tests/Doctrine/Tests/Models/DDC2775/User.php b/tests/Doctrine/Tests/Models/DDC2775/User.php deleted file mode 100644 index d42685679..000000000 --- a/tests/Doctrine/Tests/Models/DDC2775/User.php +++ /dev/null @@ -1,37 +0,0 @@ -roles[] = $role; - $role->user = $this; - } - - public function addAuthorization(Authorization $authorization) - { - $this->authorizations[] = $authorization; - $authorization->user = $this; - } -} diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2775Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2775Test.php index 6e2a61d19..bac183276 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2775Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2775Test.php @@ -2,9 +2,6 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -use Doctrine\Tests\Models\DDC2775\AdminRole; -use Doctrine\Tests\Models\DDC2775\Authorization; -use Doctrine\Tests\Models\DDC2775\User; use Doctrine\Tests\OrmFunctionalTestCase; /** @@ -14,9 +11,16 @@ use Doctrine\Tests\OrmFunctionalTestCase; */ class DDC2775Test extends OrmFunctionalTestCase { - protected function setUp() { - $this->useModelSet('ddc2775'); + protected function setUp() + { parent::setUp(); + + $this->setUpEntitySchema(array( + 'Doctrine\Tests\ORM\Functional\Ticket\User', + 'Doctrine\Tests\ORM\Functional\Ticket\Role', + 'Doctrine\Tests\ORM\Functional\Ticket\AdminRole', + 'Doctrine\Tests\ORM\Functional\Ticket\Authorization', + )); } /** @@ -39,7 +43,7 @@ class DDC2775Test extends OrmFunctionalTestCase // Need to clear so that associations are lazy-loaded $this->_em->clear(); - $user = $this->_em->find('Doctrine\Tests\Models\DDC2775\User', $user->id); + $user = $this->_em->find('Doctrine\Tests\ORM\Functional\Ticket\User', $user->id); $this->_em->remove($user); $this->_em->flush(); @@ -48,3 +52,95 @@ class DDC2775Test extends OrmFunctionalTestCase $this->_em->flush(); } } + +/** + * @Entity + * @InheritanceType("JOINED") + * @DiscriminatorColumn(name="role_type", type="string") + * @DiscriminatorMap({"admin"="AdminRole"}) + */ +abstract class Role +{ + /** + * @Id @Column(type="integer") + * @GeneratedValue + */ + public $id; + + /** + * @ManyToOne(targetEntity="User", inversedBy="roles") + */ + public $user; + + /** + * @OneToMany(targetEntity="Authorization", mappedBy="role", cascade={"all"}, orphanRemoval=true) + */ + public $authorizations; + + public function addAuthorization(Authorization $authorization) + { + $this->authorizations[] = $authorization; + $authorization->role = $this; + } +} + +/** @Entity */ +class AdminRole extends Role +{ +} + +/** + * @Entity @Table(name="authorizations") + */ +class Authorization +{ + /** + * @Id @Column(type="integer") + * @GeneratedValue + */ + public $id; + + /** + * @ManyToOne(targetEntity="User", inversedBy="authorizations") + */ + public $user; + + /** + * @ManyToOne(targetEntity="Role", inversedBy="authorizations") + */ + public $role; +} + +/** + * @Entity @Table(name="users") + */ +class User +{ + /** + * @Id @Column(type="integer") + * @GeneratedValue(strategy="AUTO") + */ + public $id; + + /** + * @OneToMany(targetEntity="Role", mappedBy="user", cascade={"all"}, orphanRemoval=true) + */ + public $roles; + + /** + * @OneToMany(targetEntity="Authorization", mappedBy="user", cascade={"all"}, orphanRemoval=true) + */ + public $authorizations; + + public function addRole(Role $role) + { + $this->roles[] = $role; + $role->user = $this; + } + + public function addAuthorization(Authorization $authorization) + { + $this->authorizations[] = $authorization; + $authorization->user = $this; + } +} diff --git a/tests/Doctrine/Tests/OrmFunctionalTestCase.php b/tests/Doctrine/Tests/OrmFunctionalTestCase.php index 57fad7db7..d2a41cfb9 100644 --- a/tests/Doctrine/Tests/OrmFunctionalTestCase.php +++ b/tests/Doctrine/Tests/OrmFunctionalTestCase.php @@ -162,12 +162,6 @@ abstract class OrmFunctionalTestCase extends OrmTestCase 'Doctrine\Tests\Models\Taxi\Car', 'Doctrine\Tests\Models\Taxi\Driver', ), - 'ddc2775' => array( - 'Doctrine\Tests\Models\DDC2775\User', - 'Doctrine\Tests\Models\DDC2775\Role', - 'Doctrine\Tests\Models\DDC2775\AdminRole', - 'Doctrine\Tests\Models\DDC2775\Authorization', - ), ); /**