I have a custom module that depends on several contrib modules. One of the contrib modules has a new version out and has switched to using entities. The code in the custom module is using node api hooks. I update it just for the change in the contrib module, there will be one hook that is using entity api e.g. hook_entity_presave().

Should I update everything to use entity api or will mixing the two be okay?

1 Answer 1


As long as you are sure everything you get will always be a node, there is no problem with mixing. Nodes are entities, after all, and node hooks and functions never got "obsolete" mark. It may be even beneficial, because you are making sure other node-related modules will continue to work with your module in a way you expect them to.

On the other hand, if you are getting something from that other module, and you can't guarantee it will always return a node, you should assume it might be any other entity, and either switch to entity approach totally, or filter what you got to make sure you only use node functions on nodes.

  • Thank you. I was concerned that mixing the two would cause problems. I think it will be okay for now but will pay close attention to what happens when the other modules update. If more switch then I will change everything.
    – Venn
    Aug 25, 2014 at 14:19

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.