Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I got an runtime error when a node's edit form is trying to save:
Notice: Undefined index: node in node_form_submit_build_node() (line 467 of /var/www/drupal-7.20/modules/node/node.pages.inc).
Here is the line that's the error is referring to:
$node = $form_state['node'];
Apparently $form_state['node'] does not exist!
I was able to get rid of the runtime by hacking the code:
if ( isset ( $form_state['node'] ) )
$node = $form_state['node'];
else if ( isset ( $form_state['complete form']['#node'] ) )
$node = $form_state['complete form']['#node'];
Comments
Comment #1
lex0r CreditAttribution: lex0r commentedOne of the sites I work on has the same issue, but it happens periodically, either on node add or node edit forms. It may happen like 5 times in a row (for 2-3 content types that are added/updated most often by site editors), and then never happen in the same scenario till next day. I don't see any pattern in it, it's a very hard to find and debug issue. Stack trace gives nothing that might help.
Anyway, I think it can be explained by some environment specifics, probably higher load, or some background processes that may influence core's state.
Comment #2
dcam CreditAttribution: dcam commentedMy guess is that the original report was caused by a contributed module manipulating the $form_state array badly.
As for @lex0r's issue, I could only make a wild guess at what the problem is. It could be caused by a contributed module or by something in the environment like you suggest. A list of the modules you have enabled might help, as well as the details on your server stack. What fields have been added to these node types? Do they have anything in common? Is there any difference between them and the unaffected node types?