Skip to content

Commit d696409

Browse files
authored
Merge pull request #1886 from Webonaute/fix-softdelete-in-future
Fix soft delete in future
2 parents cac89be + 7413760 commit d696409

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/Gedmo/SoftDeleteable/SoftDeleteableListener.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@ public function onFlush(EventArgs $args)
7171
if (isset($config['softDeleteable']) && $config['softDeleteable']) {
7272
$reflProp = $meta->getReflectionProperty($config['fieldName']);
7373
$oldValue = $reflProp->getValue($object);
74+
$date = new \DateTime();
7475

7576
// Remove `$oldValue instanceof \DateTime` check when PHP version is bumped to >=5.5
76-
if (isset($config['hardDelete']) && $config['hardDelete'] && ($oldValue instanceof \DateTime || $oldValue instanceof \DateTimeInterface)) {
77+
if (isset($config['hardDelete']) && $config['hardDelete'] && ($oldValue instanceof \DateTime || $oldValue instanceof \DateTimeInterface) && $oldValue <= $date) {
7778
continue; // want to hard delete
7879
}
7980

@@ -82,7 +83,7 @@ public function onFlush(EventArgs $args)
8283
$ea->createLifecycleEventArgsInstance($object, $om)
8384
);
8485

85-
$date = new \DateTime();
86+
8687
$reflProp->setValue($object, $date);
8788

8889
$om->persist($object);

0 commit comments

Comments
 (0)