When creating a new revision for a question node (manually), the ->save() method for the question controller is being called, which executes a drupal_goto(). Effectively none of the code after line 1173 of the node.module (as well as any other hook_node_update/hook_update implementations) is being executed due to the redirect. This includes a resetCache call to the node entity controller - the new node revision is never being cached, so subsequent load-calls are loading the old vid of the question. Other issues could also arise due to other modules (as well as node core) code not being executed.

There's a risk for loss of data, due to hooks with a weight higher than quiz not being called, and the following code from node.module NEVER being called when creating revisions for questions:

    // Save fields.
    $function = "field_attach_$op";
    $function('node', $node);

    module_invoke_all('node_' . $op, $node); // << This is where the redirect takes place in the latest dev, code below this line isn't called
    module_invoke_all('entity_' . $op, $node, 'node');

    // Update the node access table for this node.
    node_access_acquire_grants($node);

    // Clear internal properties.
    unset($node->is_new);
    unset($node->original);
    // Clear the static loading cache.
    entity_get_controller('node')->resetCache(array($node->nid));

    // Ignore slave server temporarily to give time for the
    // saved node to be propagated to the slave.
    db_ignore_slave();
  }
  catch (Exception $e) {
    $transaction->rollback();
    watchdog_exception('node', $e);
    throw $e;
  }
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

FreekVR’s picture

FreekVR’s picture

Issue summary: View changes
FreekVR’s picture

Assigned: FreekVR » Unassigned
Status: Needs work » Needs review
FileSize
2.59 KB

The attached patch moves the redirect to the form_state array, resolving the issue.

  • djdevin committed fbc8926 on 7.x-5.x authored by FreekVR
    Issue #2423363 by FreekVR: drupal_goto() called in node form submissions
    
djdevin’s picture

Status: Needs review » Fixed

Great, this is the better way to do it. Fixed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.