I have some code that is programmatically creating a node and turning over to the node form. So far it looks good and my code steps aside and lets Core do its stuff. So, the node_insert code gets called with a good node, complete with field data and a group. But then node_insert is invoked a second time with a node having the same ID, but missing group and most field data. This part makes no sense to me, and I can’t track down why it’s happening. Has anyone seen anything like this, and perhaps fixed it?
It looks like the placement of node creating code is wrong. Say for example, if we add any code in a form definition, it might get called more than once when we try to render the form using drupal_get_form().
To solve this problem, just add a debug statement (drupal_set_message) above node creation code and see how many times control comes there. if it is more than once, then our assumption is correct and probably you want to move your code to somewhere after all these processing done (and executed once). Worst case, you can check for the presence of nid and discard the insert.
On Thu, Jun 26, 2014 at 3:48 PM, Nancy Wichmann nan_wich@bellsouth.net wrote:
I have some code that is programmatically creating a node and turning over to the node form. So far it looks good and my code steps aside and lets Core do its stuff.
So, the node_insert code gets called with a good node, complete with field data and a group. But then node_insert is invoked a second time with a node having the same ID, but missing group and most field data. This part makes no sense to me, and I can't track down why it's happening.
Has anyone seen anything like this, and perhaps fixed it?
-- [ Drupal support list | http://lists.drupal.org/ ]