Creating a one-time batch import fails with the error:
PHP Fatal error: Call to undefined function sf_import_create_batchjob() in /usr/home/webster/dev.contemplativeoutreach.org/sites/all/modules/salesforce/sf_import/sf_import.admin.inc on line 255
the menu entry is defined as:
$items[SALESFORCE_PATH_ADMIN_IMPORT . '/create'] = array(
'title' => 'Batch Import',
'description' => 'Create a one-time batch import of Salesforce data',
'page callback' => 'drupal_get_form',
'page arguments' => array('sf_import_create'),
'access arguments' => array('administer salesforce'),
'file' => 'sf_import.admin.inc',
'type' => MENU_LOCAL_TASK,
);
NOTE that the menu item only includes the admin include file
> 'file' => 'sf_import.admin.inc',
while the actual sf_import_create_batchjob() function is now in the separate sf_import.batch.inc file
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | batch_includes-1293884-7.patch | 1.06 KB | klflote |
Comments
Comment #1
benjaminbradley commentedI was able to get past the "500 internal server error" by adding the following line to the top of the sf_import.admin.inc file:
include 'sf_import.batch.inc';
but I'm not sure if that's the correct solution.
My first thought was to try and get the menu entry to load multiple files with something like
'file' => array('sf_import.admin.inc', 'sf_import.batch.inc'),
but hook_menu doesn't appear to support that syntax.
In any case, even with the include line above, my batch import is still silently failing. No errors in the watchdog table, the apache log, or on the screen.
Comment #2
kostajh commentedYou would want this line
module_load_include('inc', 'sf_import', 'sf_import.batch');at the beginning offunction sf_import_create_submit(line 250).I'll try to do some work on this tomorrow.
Comment #3
Sborsody commentedYou probably need to add $batch['file'] and specify the full path to sf_import.batch.inc before calling batch_set.
Oh, I see, you're creating the batch in sf_import.batch.inc itself...
Comment #4
benjaminbradley commentedstarting with the alpha9 release,
after adding the module_load_include line to beginning of the sf_import_create_submit function in the sf_import.admin.inc file,
my one-time batch import is still failing.
no records are created.
no errors in apache log.
Drupal error log says:
Illegal offset type in ...drupal_root/includes/form.inc on line 1213.
Is there a way to get a full trace from these types of errors?
Comment #5
EvanDonovan commentedIn 7.x, the full function is like this:
Could you try changing the function in your 6.x to be something like that?
If this works, I'll make the change in 6.x. (I usually only commit to 7.x.)
Comment #6
mtbosworth commentedI have this same error.
I included the batch file in create submit and, while it fixed the php error, I still can't do batch imports. I have made some progress though. I can use the drush import, but only for salesforce user to drupal user. I may have found a bug for importing nodes. When I tried import nodes via drush I would get the error "Could not find import function for type node_". Looking through the code I found in sf_import.drush.inc starting on line 249 the following code.
// Prepare for import
$type = $map->drupal;
if (strpos($type, 'node_') === 1) {
$type = 'node';
}
$function = 'sf_' . $type . '_import';
if (!function_exists($function)) {
drush_die("Could not find import function for type " . $type);
}
This code is supposed to change the drupal type from a specific "node_" to just "node", but it wasn't since my error message was saying "node_". The problem is that strpos is returning 0, which means that "node_" was matched starting at index 0, not 1. Changing the conditional to match "node_" at index zero allows me to import nodes via drush. The fixed code looks like this:
// Prepare for import
$type = $map->drupal;
if (strpos($type, 'node_') === 0) {
$type = 'node';
}
$function = 'sf_' . $type . '_import';
if (!function_exists($function)) {
drush_die("Could not find import function for type " . $type);
}
However, the batch operation in the admin still fails. I set up a bunch of dd's in the salesforce code to investigate and the operation function which is specified for the batch is never called.
I hope this helps move toward a solution for the batch import problem in drupal 6.
Comment #7
klflote commentedThe reason that the function specified for the batch is never called is because the batch also needs to know where to find the function definition; when the batch is defined (in sf_import_create_batchjob), it should be given a file argument:
Attached is a patch that addresses both include issues; apply it to the dev branch of the code and batch importing should work (it works for me now).
Comment #8
kostajh commentedCommitted, thank you @klflote! http://drupalcode.org/project/salesforce.git/commit/7905bab
Comment #9
kostajh commentedComment #10
EvanDonovan commentedThanks, this should fix in 7.x as well. I'll try to commit soon.
Comment #11
kostajh commentedCommitted patch from #7 to 7.x-2.x-dev http://drupalcode.org/project/salesforce.git/commit/04fc211
Comment #12
Fixdit commentedThanks for the update.
I upgraded to the latest Dev 7.x-2.x, but got this error on batch import. Any idea what's happening?
Message:
Error on prior import progress bar page:
I need to be able to import a user base from Salesforce -> Drupal via this method. Is that what it's designed for?
Many thanks in advance,
Comment #13
kostajh commentedThe import/export functionality does not work well out of the box for user accounts. You'll need to implement `hook_salesforce_api_pre_import()`, look at the data you are getting from Salesforce, and halt processing on records where, for example, the field you've mapped to a username is '', which is what I think is happening in your error message above.
Comment #15
nicodv commentedHi Kostajh, I also get something similar (An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: /batch?id=266&op=do StatusText: Service unavailable (with message) ResponseText: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '267-6' for key 1: INSERT INTO {users_roles} (uid, rid) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1); Array ( [:db_insert_placeholder_0] => 267 [:db_insert_placeholder_1] => 6 ) in user_save() (line 599 of /home/theveryl/public_html/kings/modules/user/user.module). )
...but i don't know how to fix it with the hint you explained (i'm not a coder) : "...You'll need to implement `hook_salesforce_api_pre_import()..."
How and where should I implement this hook? (in case it is the fix form me too)
Thanks a lot in advance
nico
Comment #16
nicodv commented@Fixdit. I'm having a very similar trouble with salesforce, but I'm no expert coder and I really don't know where to apply the hook recommended by kostajh. Could you give some hint on this in case it worked for you? I have to import a batch of users and I think my problem is having the username mapped, but I don't want to map it to a sustitutive field.
Well, if you have some time for this I would really appreciate it.
Thanks in advance
nico