[support] drupal_form_submit updating not inserting on multiple record submission

Chad Fennell libsys at gmail.com
Wed Feb 16 23:54:46 UTC 2011


So, there is this, uh, guy I know who can't seem to grok what is
happening in the new D7 drupal_form_submit() function when he is
submitting multiple nodes at a time (e.g. looping over a file of
records for import).  What appears to be happening is this: the first
record is submitted and inserted within node_save() function.  The nid
from this record is retained/cached/whatever, so node_save() sees any
subsequently submitted records as already having a nid and therefor
treats them as updates to the first insert instead of as new new
nodes.   So, if I were to do something like:
http://drupalbin.com/17729

The only new record I see is "foo-#1", foo-#1 having overwritten foo-#0.

So, I guess I'm wondering if is this expected behavior and I'm just
not passing the node form everything it needs? Or possibly my install
is somehow scrogged? Or?

BTW, I noticed that if I just hack node_form() to generate a fresh
node object each submit with:

node_object_prepare($node);
$form_state['node'] = $node;

The problem goes away.  But, I don't really know why yet.

Thanks much!
-Chad

P.S. I'm aware of and love the feeds module but still want to
understand this problem :).


More information about the support mailing list