insert listener shouldn't intercept recursion->generate process
authorpriyankakaran26 <priyanka.karan26@gmail.com>
Sat, 18 Oct 2014 23:33:07 +0000 (00:33 +0100)
committerpriyankakaran26 <priyanka.karan26@gmail.com>
Sat, 18 Oct 2014 23:33:07 +0000 (00:33 +0100)
CRM/Core/BAO/RecurringEntity.php

index 647ffbc0a2317f6d881c1bd9ccca3dccbcfcbac0..3e636dd971d10ad83c759457e18f944e65fbb75d 100644 (file)
@@ -53,6 +53,8 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity {
   protected $recursion = NULL;
   
   public static $_entitiesToBeDeleted = array();
+
+  public static $status = NULL;
   
   static $_recurringEntityHelper = 
     array(
@@ -239,6 +241,8 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity {
    * @return array
    */
   function generateEntities() {
+    self::$status = "Running"; 
+
     $newEntities  = array();
     $findCriteria = array();
     if (!empty($this->recursionDates)) {
@@ -292,6 +296,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity {
       }
     }
 
+    self::$status = NULL;
     return $newEntities;
   }
 
@@ -623,6 +628,11 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity {
       return NULL;
     }
 
+    if (self::$status == 'Running') {
+      // if recursion->generate() is doing some work, lets not intercept
+      return NULL;
+    }
+
     // mark being processed
     $processedEntities[$key] = 1;