CRM_Core_BAO_ActionSchedule::deleteRecord($params);
unset($params['id']);
}
+ $dbParams['name'] = 'repeat_' . $params['used_for'] . '_' . $params['entity_id'];
$actionScheduleObj = CRM_Core_BAO_ActionSchedule::writeRecord($dbParams);
//exclude dates
}
}
- //Set type for API
+ // FIXME: This is the worst way possible to convert a table name to an api entity name
$apiEntityType = explode("_", $type);
if (!empty($apiEntityType[1])) {
$apiType = $apiEntityType[1];
if (!empty(CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]['pre_delete_func']) &&
!empty(CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]['helper_class'])
) {
- $preDeleteResult = call_user_func_array(CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]['pre_delete_func'], [$params['entity_id']]);
- if (!empty($preDeleteResult)) {
- call_user_func([CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]['helper_class'], $preDeleteResult]);
- }
+ // FIXME: This calls `CRM_Event_Form_ManageEvent_Repeat::checkRegistrationForEvents`
+ // which then sets the static variable `CRM_Core_BAO_RecurringEntity::$_entitiesToBeDeleted`
+ // which is then accessed below and used to delete events with no registrations.
+ // I can't think of a worse way to pass a variable back from a function.
+ call_user_func_array(CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]['pre_delete_func'], [$params['entity_id']]);
}
//Ready to execute delete on entities if it has delete function set
if (!empty(CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]['delete_func']) &&
{* file to handle db changes in 5.66.alpha1 during upgrade *}
{* Ensure action_schedule.name has a unique value *}
-UPDATE `civicrm_action_schedule` SET name = CONCAT('reminder_', id) WHERE name IS NULL OR name = '';
+UPDATE `civicrm_action_schedule` SET name = COALESCE(CONCAT('repeat_', used_for, '_', entity_value), CONCAT('schedule_', id)) WHERE name IS NULL OR name = '';
UPDATE `civicrm_action_schedule` a1, `civicrm_action_schedule` a2
SET a2.name = CONCAT(a2.name, '_', a2.id)
WHERE a2.name = a1.name AND a2.id > a1.id;