I am using the Salesforce module with the Location module to track addresses for users. Updates made to Salesforce fields mapped to Location module fields do not update in Drupal when the import process is run. The problem is in _sf_contrib_import_location(), specifically in loop that updates address fields when a primary address is set:

  foreach ($object->locations as $location) {
    if ($location['is_primary'] == 1) {
      $location[$drupal_fieldname] = $sf_data->{$sf_fieldname};
      return;
    }
  }

The passed in object (a node in this case), is passed in by reference, but the loop just updates a variable local to the function foreach loop: $location. Unless I'm missing something, I can't see any reason why it shouldn't just update the object directly (since only $object is passed by reference, and the whole point of sf_node_import() is to make changes to $node):

  foreach ($object->locations as $location) {
    if ($location['is_primary'] == 1) {
      $object->locations[0][$drupal_fieldname] = $sf_data->{$sf_fieldname};
      return;
    }
  }

I've confirmed this fixes the issue on my installation. Patch coming shortly.

Comments

jemond’s picture

Status: Active » Needs review
StatusFileSize
new536 bytes

Patch to fix issue attached.

jemond’s picture

Small bug in my patch. Attached fixed patch.

jemond’s picture

Issue summary: View changes

Fix typo

aaronbauman’s picture

Issue summary: View changes
Status: Needs review » Closed (outdated)

closing all 6.x issues