node_validate is called once by node_form_validate, then again by node_form_execute. This is cruft from long ago, and can cause problems with node module altering the node twice on hook_validate. The root problem is that hook_validate is used to both validate and set form errors, and also alter the node object before node_save. This patch decouples the two operations, so that hook_validate only is used to validate form fields and set form errors, and a new node module hook hook_execute is called to allow node modules to alter the node object prior to node_save. This issue is even more apparent with the new form api, where you have two distinct validate and execute functions. Node modules will need to be updated if they modify the node object on hook_validate.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

crunchywelch’s picture

FileSize
11.37 KB

Here is a patch which includes the required changes to the affected core node modules. Most just removed the pass by refernece of the node object on hook_validate

adrian’s picture

FileSize
2.05 KB

+1

Aaron is right, the only reason the function is called twice is cruft related.

adrian’s picture

That was weird. i meant to upload that patch to a issue on another tab. did i upload it to the wrong one, or did it pick it out of the session ?

Steven’s picture

Status: Needs review » Fixed

Committed to head.

Anonymous’s picture

Status: Fixed » Closed (fixed)