Diff module, from what i've seen works with node revision differences, not node edit submission diff.

Is diffing any entity-related form submission possible programmatically through Diff module API? Suppose i alter node_form_submit() in my module and i want to record in watchdog the watchdog message the diff if this is a node edit event.

I try with diff_entity_diff($old_entity, $new_entity, $context) but i get no title changes and i'm not sure how to render this output.

Or in other words, which is the best way to get the diff of the submitted values of any form? (compare form_states)


1 Answer 1


Problem is - diff compares entities and their revisions. But node_form_submit() happens before revision is created. If you will inspect node_save, you will see no hooks are called after actual save.

To get your code executed and be sure revision is there, it would be tempting to use Rules, but existing bug "After updating existing content" runs before content is saved. shows it has just the same issues as hooks. Maintainers say:

We just rely on the hooks drupal provides us here.

So now you have 2 options:

  1. Give up on using diff module and just borrow some of it's code (it's open source after all)
  2. On save, set a hidden field "test with diff" to true, and on cron make actual testing. With */5 minutes CRON it will be almost as good, as instantaneous test.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.