From: Pengyi Zhang Date: Wed, 14 Aug 2019 23:32:37 +0000 (+1000) Subject: CIVICRM-1223 adopt to the latest When package and handle error when generate recursion X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=2ba9aad67c8c7b0f7ae2cd0447148f0119ab6e53;p=civicrm-core.git CIVICRM-1223 adopt to the latest When package and handle error when generate recursion --- 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']) {