From 2ba9aad67c8c7b0f7ae2cd0447148f0119ab6e53 Mon Sep 17 00:00:00 2001 From: Pengyi Zhang Date: Thu, 15 Aug 2019 09:32:37 +1000 Subject: [PATCH] CIVICRM-1223 adopt to the latest When package and handle error when generate recursion --- CRM/Core/BAO/RecurringEntity.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/CRM/Core/BAO/RecurringEntity.php b/CRM/Core/BAO/RecurringEntity.php index daf86a7806..57af4051b4 100644 --- a/CRM/Core/BAO/RecurringEntity.php +++ b/CRM/Core/BAO/RecurringEntity.php @@ -31,7 +31,7 @@ * @copyright CiviCRM LLC (c) 2004-2019 */ -require_once 'packages/When/When.php'; +use When\When; /** * Class CRM_Core_BAO_RecurringEntity. @@ -334,7 +334,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { $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; @@ -344,7 +344,14 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { } $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 @@ -1010,7 +1017,8 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { $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']) { -- 2.25.1