From: Pengyi Zhang Date: Wed, 11 Sep 2019 06:41:30 +0000 (+1000) Subject: CIVICRM-1223 fix errors X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=4e12f3b2c1fd59f504557898a615d2f1515df99c;p=civicrm-core.git CIVICRM-1223 fix errors --- diff --git a/CRM/Core/BAO/RecurringEntity.php b/CRM/Core/BAO/RecurringEntity.php index 57af4051b4..a74f8ca35e 100644 --- a/CRM/Core/BAO/RecurringEntity.php +++ b/CRM/Core/BAO/RecurringEntity.php @@ -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); } diff --git a/tests/phpunit/CRM/Core/BAO/RecurringEntityTest.php b/tests/phpunit/CRM/Core/BAO/RecurringEntityTest.php index 4c0e6563a2..008a052055 100644 --- a/tests/phpunit/CRM/Core/BAO/RecurringEntityTest.php +++ b/tests/phpunit/CRM/Core/BAO/RecurringEntityTest.php @@ -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',