Details
Description
I reported this bug on the symfony site, but after investigation i have found that it is actually a doctrine SoftDelete issue. http://trac.symfony-project.org/ticket/8898
I have a sandbox replicating the problem here:
http://dl.dropbox.com/u/8354765/sf_sandbox.zip
Run the test:
./symfony test:unit Contact
The issue is I want to hard delete my M-M link table and soft delete the parents. This fails. I believe it is to do with the fact that the relations to the parent are marked as Doctrine_Record::STATE_TCLEAN which when the SoftDelete calls save on the parent object this flag trys to reinsert the relations that it has deleted. Things go very wrong at this point and the connection is rolled back.
The fix I have is the following, not sure what this would do to other things or not as I am not overly familiar with Doctrine internals...
Index: Doctrine/Template/Listener/SoftDelete.php
===================================================================
--- Doctrine/Template/Listener/SoftDelete.php (revision 12962)
+++ Doctrine/Template/Listener/SoftDelete.php (working copy)
@@ -95,6 +95,7 @@
public function postDelete(Doctrine_Event $event)
{
if ( ! $this->_options['hardDelete']) {
+ $event->getInvoker()->clearRelated();
$event->getInvoker()->save();
}
}
This works even if the relations have been marked as SoftDelete.
Formatting