CIVICRM-1223 fix errors
authorPengyi Zhang <pengyi@agileware.com.au>
Wed, 11 Sep 2019 06:41:30 +0000 (16:41 +1000)
committerSeamus Lee <seamuslee001@gmail.com>
Thu, 3 Oct 2019 08:07:32 +0000 (18:07 +1000)
CRM/Core/BAO/RecurringEntity.php
tests/phpunit/CRM/Core/BAO/RecurringEntityTest.php

index 57af4051b441a1323cc2868dc90e905c69de340d..a74f8ca35e8ed5846db846d55aa8b2d1af50bfdb 100644 (file)
@@ -345,18 +345,14 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity {
 
       $count = 1;
       try {
+        $this->recursion->RFC5545_COMPLIANT = When::IGNORE;
         $this->recursion->generateOccurrences();
       }
       catch (Exception $e) {
-        CRM_Core_Error::statusBounce($e->getMessage());
+        CRM_Core_Session::setStatus(ts($e->getMessage()));
         return $recursionDates;
       }
       foreach ($this->recursion->occurrences as $result) {
-        $skip = FALSE;
-        if ($result == $this->recursion_start_date) {
-          // skip the recursion-start-date from the list we going to generate
-          $skip = TRUE;
-        }
         $baseDate = $result->format('YmdHis');
 
         foreach ($this->dateColumns as $col) {
@@ -390,15 +386,6 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity {
           }
         }
 
-        if ($skip) {
-          unset($recursionDates[$count]);
-          if ($initialCount && ($initialCount > 0)) {
-            // lets increase the counter, so we get correct number of occurrences
-            $initialCount++;
-            $this->recursion->count($initialCount);
-          }
-          continue;
-        }
         $count++;
       }
     }
@@ -1018,6 +1005,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity {
         }
         $repetition_frequency_unit = $repetition_frequency_unit . 'ly';
         $r->startDate($start)
+          ->exclusions([$start])
           ->freq($repetition_frequency_unit);
       }
 
index 4c0e6563a2be00394f65d7e69d0ce506729413db..008a052055201573ecc7f29630c5d57cb8d9411b 100644 (file)
@@ -75,10 +75,10 @@ class CRM_Core_BAO_RecurringEntityTest extends CiviUnitTestCase {
     $this->assertEquals(5, count($generatedEntities['civicrm_activity']), "Cehck if number of iterations are 5");
     $expectedDates = [
       '20141025103000',
-      '20141227103000',
-      '20150328103000',
-      '20150627103000',
-      '20150926103000',
+      '20150124103000',
+      '20150425103000',
+      '20150725103000',
+      '20151024103000',
     ];
     foreach ($generatedEntities['civicrm_activity'] as $entityID) {
       $this->assertDBNotNull('CRM_Activity_DAO_Activity', $entityID, 'id',