API page: http://api.drupal.org/api/drupal/includes%21form.inc/function/drupal_pro...

I'm writing a migration from a 3rd party CMS and ran into this issue. When trying to update a node, the values passed in using $form_state['values'] were overwritten to an empty array by the first line in this function:

function drupal_process_form($form_id, &$form, &$form_state) {
  $form_state['values'] = array();

After commenting out the line, my API calls were successful, but the UI broke, so I'm assuming somewhere this function is called without $form_state['values'] being set, hence the initial setting. I modified the function to check for the values instead and both API and UI are now working as expected:

function drupal_process_form($form_id, &$form, &$form_state) {
    if (!isset($form_state['values'])) {
      $form_state['values'] = array();
    }

Comments

marcingy’s picture

Category: bug » support

If you are trying to process a node programatical and maintain a form state you should use drupal_form_submit or utilise node_save if you can validate the data.

petermonica’s picture

Thanks, I actually am using drupal_form_submit. The last line of that function calls drupal_process_form, which is where I encountered the error.

petermonica’s picture

Priority: Normal » Major

Bumping the priority on this. Services module is partially non-functioning due to this error.

cilefen’s picture

Category: Support request » Bug report
Issue summary: View changes

Status: Active » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.