sf_node: Call to sf_node_import triggers call to sf_node_export

aaronbauman - May 11, 2009 - 17:06
Project:Salesforce
Version:6.x-2.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:aaronbauman
Status:closed
Description

Calling sf_node_import fires node_save, which triggers the update operation in sf_node_nodeapi and results in a sf_node_export call.

An "import" should only import, not import then export.
ie. There should be a way to disable outbound nodeapi operations when performing imports.
Otherwise, we could run into recursion problems, not to mention unnecessary SalesForce API calls.

Consider a simple case where the user has enabled salesforce outbound SOAP messaging:

  1. import a record from salesforce
  2. save record as a drupal node
  3. export the record back to salesforce
  4. Salesforce triggers an outbound message back to Drupal
  5. go back to #1

Consider a case of mass imports:
Using a few SalesForce API calls, I query for and gather all the SF data I want to import -- possibly thousands of records, but all returned in a relatively small number of queries. Then for each imported node, node_save() invokes a sf_node_export() -- an extra API call for each node.

Dunno if this is the optimal method, but the attached patch implements a node property "sf_node_skip_export" that short-circuits nodeapi operations on sf_node_import.

AttachmentSize
import-export-issue.patch1.57 KB

#1

Sid_M - July 28, 2009 - 10:08
Status:needs review» reviewed & tested by the community

I have tested this. It works as advertised. Since it is fixing a very real bug which occurs whenever one imports, I recommend committing this patch.

#2

Bevan - July 31, 2009 - 03:25
Status:reviewed & tested by the community» fixed

http://drupal.org/cvs?commit=245214

I didn't test this explicitly but I trust aaron's call on this one, the solution makes sense and the patch is clean.

#3

Bevan - July 31, 2009 - 04:26

I tweaked this to use return instead of break for style consistency. functionality would not be changed by this: http://drupal.org/cvs?commit=245242

#4

System Message - August 14, 2009 - 04:30
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.