Hi,
in Drupal 6, I use hook_nodeapi to catch when a node is created with
case 'insert' ...that allows me to programmatically set up links with and store some info about that newly created node.
My problem is when I come to delete a node, once again I use hook_nodeapi with
case 'delete' ...that allows me to programmatically clear up links and remove info about the node that is being deleted, however...
it seems that hook_nodeapi is called with case 'insert' AFTER it has been called with case 'delete'
So any operation invoked by the 'delete' stage will be superceded with an operation invoked by the 'insert' stage, its antithesis!
Any ideas on how I can avoid this scenario and what's going on would be much appreciated :-)
Hi Nicholas,It's difficult to
Hi Nicholas,
It's difficult to know for certain without seeing your code but it sounds as if you have a switch statement that isn't breaking properly.
That is, where your hook_nodeapi() should look like
<code>
hook_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
switch($op) {
case 'delete':
// delete actions here
break;
case 'insert':
// insert actions here
break;
}
</code>
It actually looks like:
<code>
hook_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
switch($op) {
case 'delete':
// delete actions here
case 'insert':
// insert actions here
// NB because there's no 'break' above
// these will be called even when $op == 'delete'
break;
}
</code>