Doctrine 1
  1. Doctrine 1
  2. DC-795

Can't mix Soft and Hard deletes. Fix with patch provided.

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.2
    • Fix Version/s: 1.2.2
    • Component/s: Behaviors
    • Labels:
      None
    • Environment:
      Mac

      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.

        Activity

        Hide
        John Wards added a comment -

        Formatting

        Show
        John Wards added a comment - Formatting
        Hide
        Jonathan H. Wage added a comment -

        Does this patch pass the test suite?

        Show
        Jonathan H. Wage added a comment - Does this patch pass the test suite?
        Hide
        John Wards added a comment -

        I have run the test suite and got the same 8 failures with and without the patch.

        These are the failing tests:
        Doctrine_Cache_Apc_TestCase
        Doctrine_Cache_Abstract_TestCase
        Doctrine_Ticket_1783_TestCase

        Anything obvious I need to do to get these working, other than enabling apc...

        Show
        John Wards added a comment - I have run the test suite and got the same 8 failures with and without the patch. These are the failing tests: Doctrine_Cache_Apc_TestCase Doctrine_Cache_Abstract_TestCase Doctrine_Ticket_1783_TestCase Anything obvious I need to do to get these working, other than enabling apc...
        Hide
        John Wards added a comment -

        It seems to be passing all the tests that have SoftDelete in them however, so I would say that it is working as expected.

        Show
        John Wards added a comment - It seems to be passing all the tests that have SoftDelete in them however, so I would say that it is working as expected.

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            John Wards
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: