Hi,
I am the author of Drigg. For Drigg, I use a custom-made node type, "drigg", which works great.
What I am _really_ missing is a hook which should be called by node_save() to see if it's actually *OK* to save a node *before* the initial INSERT (into the table 'node') is done to the database.
The reason? Well, the node_drigg table (which extends "node") has a constraint: the "link" field is a unique key. So, two nodes CANNOT have the same link. However, when my module's nodeapi hook gets finally called, the initial insert has already happened!
Basically, I need Drigg to be able to *veto* the save. Yes, I know that hook_nodeapi is called with $op "validate", but that only happens in forms. Modules like Mailhandler, or node_import, DON'T do that - they just hit node_save(), and that basically creates problems.
I am happy to write the patch (which really is tiny) for this to happen. I can't think of a good name for $op though.
Now... ideas? Comments?
Thanks a lot,
Merc.
Comments
Comment #1
mercmobily commentedHi,
Am I the only module developer who could possibly want this...?
(Not complaining... it might well be!)
Merc.
Comment #2
tstoecklerStill valid.
There is now hook_node_presave, but the node gets saved nonetheless.
Comment #3
marcingy commentedShouldn't this be being done a form validation step? ie module X does a check on field or what and says hey you can't save because X already exists. Once node_save process starts ineffect we are saying we are happy with the data we have and it is valid. I'm tempted to mark as won't fix because the attempt to incept is too late in the life cycle but want some agreement first.
This is reason also why a programatic form submission exists.
Comment #4
tstoecklerI think the use-case is pretty valid.
If you have a module which imposes certain restrictions on node properties or fields, there is no way to enforce them.
Right now you node_save() fails if you set a nid but not a vid. What if I create a super_revisions module which uses svid and I would like to impose the same restriction?
Comment #11
dpiHurrah, Entity validation!