Skip to content

Commit 1150926

Browse files
authored
Revert "[SoftDeleteable] Detach soft-deleted objects from entity manager after flush"
1 parent f61d144 commit 1150926

File tree

2 files changed

+1
-53
lines changed

2 files changed

+1
-53
lines changed

lib/Gedmo/SoftDeleteable/SoftDeleteableListener.php

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,6 @@ class SoftDeleteableListener extends MappedEventSubscriber
2929
*/
3030
const POST_SOFT_DELETE = "postSoftDelete";
3131

32-
/**
33-
* Objects soft-deleted on flush.
34-
*
35-
* @var array
36-
*/
37-
private $softDeletedObjects = array();
38-
3932
/**
4033
* {@inheritdoc}
4134
*/
@@ -44,7 +37,6 @@ public function getSubscribedEvents()
4437
return array(
4538
'loadClassMetadata',
4639
'onFlush',
47-
'postFlush'
4840
);
4941
}
5042

@@ -100,32 +92,10 @@ public function onFlush(EventArgs $args)
10092
self::POST_SOFT_DELETE,
10193
$ea->createLifecycleEventArgsInstance($object, $om)
10294
);
103-
104-
$this->softDeletedObjects[] = $object;
10595
}
10696
}
10797
}
10898

109-
/**
110-
* Detach soft-deleted objects from object manager.
111-
*
112-
* @param \Doctrine\Common\EventArgs $args
113-
*
114-
* @return void
115-
*
116-
* @throws \Gedmo\Exception\InvalidArgumentException
117-
*/
118-
public function postFlush(EventArgs $args)
119-
{
120-
$ea = $this->getEventAdapter($args);
121-
$om = $ea->getObjectManager();
122-
123-
foreach ($this->softDeletedObjects as $index => $object) {
124-
$om->detach($object);
125-
unset($this->softDeletedObjects[$index]);
126-
}
127-
}
128-
12999
/**
130100
* Maps additional metadata
131101
*

tests/Gedmo/SoftDeleteable/SoftDeleteableEntityTest.php

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -76,28 +76,6 @@ public function shouldBeAbleToHardDeleteSoftdeletedItems()
7676
$this->assertNull($user);
7777
}
7878

79-
/**
80-
* @test
81-
*/
82-
public function shouldNotFetchSoftDeletedItemByIdIfDetachOnDeleteEnabled()
83-
{
84-
$repo = $this->em->getRepository(self::USER_CLASS);
85-
86-
$newUser = new User();
87-
$newUser->setUsername('test_user');
88-
89-
$this->em->persist($newUser);
90-
$this->em->flush();
91-
92-
$userId = $newUser->getId();
93-
94-
$this->em->remove($newUser);
95-
$this->em->flush();
96-
97-
$user = $repo->find($userId);
98-
$this->assertNull($user);
99-
}
100-
10179
/**
10280
* @test
10381
*/
@@ -598,7 +576,7 @@ protected function getUsedEntityFixtures()
598576
self::OTHER_ARTICLE_CLASS,
599577
self::OTHER_COMMENT_CLASS,
600578
self::MAPPED_SUPERCLASS_CHILD_CLASS,
601-
self::USER_NO_HARD_DELETE_CLASS
579+
self::USER_NO_HARD_DELETE_CLASS,
602580
);
603581
}
604582
}

0 commit comments

Comments
 (0)