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 authored and seamuslee001 committed Sep 6, 2019
1 parent e8f6269 commit cbe9baa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
16 changes: 12 additions & 4 deletions CRM/Core/BAO/RecurringEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* @copyright CiviCRM LLC (c) 2004-2019
*/

require_once 'packages/When/When.php';
use When\When;

/**
* Class CRM_Core_BAO_RecurringEntity.
Expand Down Expand Up @@ -334,7 +334,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 +344,14 @@ 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 +1017,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
3 changes: 3 additions & 0 deletions Civi/API/Provider/MagicFunctionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ protected function resolve($apiRequest) {
foreach ($stdFiles as $stdFile) {
if (\CRM_Utils_File::isIncludable($stdFile)) {
require_once $stdFile;
if ($apiRequest['entity'] == 'Geometry' && $apiRequest['action'] == 'create') {
print_r($stdFunction);
}
if (function_exists($stdFunction)) {
$this->cache[$cachekey] = ['function' => $stdFunction, 'is_generic' => FALSE];
return $this->cache[$cachekey];
Expand Down

0 comments on commit cbe9baa

Please sign in to comment.