Commit 06c06a65 authored by B_man's avatar B_man
Browse files

Move the rest of the sync logic up into the try

parent 937b554b
......@@ -6560,18 +6560,22 @@ function drupalorg_salesforce_pull_entity_update($account, $sf_object, $sf_mappi
"Drupal_uid_int__c" => 'Drupal_uid_int__c',
];
$query_results = $salesforce->query($query);
// If a salesforce contact has a drupal.org UID, don't bother pushing a UID to salesforce
$wrapper = entity_metadata_wrapper('user', $account);
if (empty($query_results['records'][0]['Drupal_uid_int__c']) && $wrapper->field_da_ind_membership->value()) {
$entity_type = 'user';
$entity = $account;
$sf_sync_trigger = SALESFORCE_MAPPING_SYNC_DRUPAL_UPDATE;
$mapping = salesforce_mapping_load('uidpush');
$sf_push = salesforce_push_sync_rest($entity_type, $entity, $mapping, $sf_sync_trigger);
watchdog('drupalorg salesforce push', 'Salesforce push for @name', ['@name' => $account->name], WATCHDOG_INFO);
}
} catch (SalesforceException $e) {
watchdog('drupalorg salesforce pull', 'Salesforce pull for @name errored: @error', ['@name' => $account->name, '@error' => $e->getMessage()], WATCHDOG_ERROR);
}
// If a salesforce contact has a drupal.org UID, don't bother pushing a UID to salesforce
$wrapper = entity_metadata_wrapper('user', $account);
if (empty($query_results['records'][0]['Drupal_uid_int__c']) && $wrapper->field_da_ind_membership->value()) {
$entity_type = 'user';
$entity = $account;
$sf_sync_trigger = SALESFORCE_MAPPING_SYNC_DRUPAL_UPDATE;
$mapping = salesforce_mapping_load('uidpush');
$sf_push = salesforce_push_sync_rest($entity_type, $entity, $mapping, $sf_sync_trigger);
watchdog('drupalorg salesforce push', 'Salesforce push for @name', ['@name' => $account->name], WATCHDOG_INFO);
watchdog('drupalorg salesforce pull', 'Salesforce pull for @name errored: @error', [
'@name' => $account->name,
'@error' => $e->getMessage(),
], WATCHDOG_ERROR);
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment