Examine the following trivial code:

$node = node_load(123);
node_save($node);

This code will cause bookmarks of "Show on Form" type to get deleted. That's because views_bookmark_nodeapi('update') assumes the $node->views_bookmark checkboxes array is always present. But this array is present only when the node is saved through a form, not when a node is saved directly via node_save(). Note that the Actions module saves node via node_save(), which means that our module isn't compatible with it.

I'm attaching a patch.

The fix could be simply to do if (!isset($node->views_bookmark)) { return; } in views_bookmark_nodeapi(). However, I prefered to revamp the code there. No need for all the current logic, becuase it's done in hook_form_alter() already. FAPI takes care of security for us.

CommentFileSizeAuthor
vbm_nodeapi.diff1.23 KBmooffie

Comments

quicksketch’s picture

Status: Needs review » Fixed

This sounds great to me. I tested it out and couldn't find any problems. I love the simplification of the logic. Applied to 5.x. Great catch and a big thank you!

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.