Skip to content

Commit

Permalink
CIVICRM-1223 adopt to the latest When package and handle error when g…
Browse files Browse the repository at this point in the history
…enerate recursion
  • Loading branch information
agileware-pengyi committed Aug 14, 2019
1 parent 79ccdcd commit 7355d78
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions CRM/Core/BAO/RecurringEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@
* @copyright CiviCRM LLC (c) 2004-2019
*/

require_once 'packages/When/When.php';
require_once 'packages/When/src/Valid.php';
require_once 'packages/When/src/When.php';

use When\When;
/**
* Class CRM_Core_BAO_RecurringEntity.
*/
Expand Down Expand Up @@ -334,7 +336,7 @@ public function generateRecursiveDates() {
$this->generateRecursion();

$recursionDates = [];
if (is_a($this->recursion, 'When')) {
if (is_a($this->recursion, 'When\When')) {
$initialCount = CRM_Utils_Array::value('start_action_offset', $this->schedule);

$exRangeStart = $exRangeEnd = NULL;
Expand All @@ -344,7 +346,13 @@ public function generateRecursiveDates() {
}

$count = 1;
while ($result = $this->recursion->next()) {
try {
$this->recursion->generateOccurrences();
} catch (Exception $e) {
CRM_Core_Error::statusBounce($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
Expand Down Expand Up @@ -1010,7 +1018,8 @@ public function getRecursionFromSchedule($scheduleReminderDetails = []) {
$repetition_frequency_unit = "dai";
}
$repetition_frequency_unit = $repetition_frequency_unit . 'ly';
$r->recur($start, $repetition_frequency_unit);
$r->startDate($start)
->freq($repetition_frequency_unit);
}

if ($scheduleReminderDetails['repetition_frequency_interval']) {
Expand Down

0 comments on commit 7355d78

Please sign in to comment.