From d29b0fe7338cb15944bcca3137c87c4eeeca6988 Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 14 Dec 2017 14:51:21 +1300 Subject: [PATCH] CRM-21551 Add parameter to support skipping processing greetings when calling api contact.create --- CRM/Contact/BAO/Contact.php | 7 ++++++- api/v3/Contact.php | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CRM/Contact/BAO/Contact.php b/CRM/Contact/BAO/Contact.php index 866c823702..ee0f3fa3b1 100644 --- a/CRM/Contact/BAO/Contact.php +++ b/CRM/Contact/BAO/Contact.php @@ -437,7 +437,12 @@ class CRM_Contact_BAO_Contact extends CRM_Contact_DAO_Contact { } } - self::processGreetings($contact); + // In order to prevent a series of expensive queries in intensive batch processing + // api calls may pass in skip_greeting_processing, probably doing it later via the + // scheduled job. CRM-21551 + if (empty($params['skip_greeting_processing'])) { + self::processGreetings($contact); + } return $contact; } diff --git a/api/v3/Contact.php b/api/v3/Contact.php index 2f93c1b4b7..5e4149898a 100644 --- a/api/v3/Contact.php +++ b/api/v3/Contact.php @@ -153,6 +153,12 @@ function _civicrm_api3_contact_create_spec(&$params) { 'description' => 'Throw error if contact create matches dedupe rule', 'type' => CRM_Utils_Type::T_BOOLEAN, ); + $params['skip_greeting_processing'] = array( + 'title' => 'Skip Greeting processing', + 'description' => 'Do not process greetings, (these can be done by scheduled job and there may be a preference to do so for performance reasons)', + 'type' => CRM_Utils_Type::T_BOOLEAN, + 'api.default' => 0, + ); $params['prefix_id']['api.aliases'] = array('individual_prefix', 'individual_prefix_id'); $params['suffix_id']['api.aliases'] = array('individual_suffix', 'individual_suffix_id'); $params['gender_id']['api.aliases'] = array('gender'); -- 2.25.1