take care of residues in recurring entity table
authorpriyankakaran26 <priyanka.karan26@gmail.com>
Fri, 14 Nov 2014 18:12:30 +0000 (18:12 +0000)
committerpriyankakaran26 <priyanka.karan26@gmail.com>
Fri, 14 Nov 2014 18:12:30 +0000 (18:12 +0000)
CRM/Core/Form/RecurringEntity.php

index ec7a494bb8c97d5a4116f0725d6a4ed434cb3cad..193027768dcfc6f73843a47da007d94e4650bf51 100644 (file)
@@ -442,8 +442,13 @@ class CRM_Core_Form_RecurringEntity {
               }\r
             }\r
           }\r
-          // lets delete current entity from recurring-entity table, which is going to be a new parent\r
-          CRM_Core_BAO_RecurringEntity::delEntity($params['entity_id'], $params['entity_table'], TRUE);\r
+\r
+          // find all entities from the recurring set. At this point we 'll get entities which were not deleted \r
+          // for e.g due to participants being present. We need to delete them from recurring tables anyway.\r
+          $pRepeatingEntities = CRM_Core_BAO_RecurringEntity::getEntitiesFor($params['entity_id'], $params['entity_table']);\r
+          foreach($pRepeatingEntities as $val) {\r
+            CRM_Core_BAO_RecurringEntity::delEntity($val['id'], $val['table'], TRUE);\r
+          }\r
         }\r
 \r
         $recursion = new CRM_Core_BAO_RecurringEntity();\r