Hi Davy!
First thanks for your module, it's very useful and also one of my favorites when a site needs search.
My problem was that when updating a node the index was saving the past version, not the updated version.
Looking at the code I think that the problem is that when you call _node_index_node (under instant_search_exit) you have no control over the Drupal cache, and the node loaded in this function is the cached node, not the updated version... In other words, _node_index_node calls node_load without using the reset parameter, causing a problem when indexing. That's also an explanation why your module works good with new nodes, and it's because new nodes can't be cached.
So... the function instant_search_nodeapi should (in my opinion) look like this...
function instant_search_nodeapi(&$node, $op, $arg = 0) {
switch ($op) {
case 'update':
node_load($node->nid,null,true);
case 'insert':
// when inserting or updating a node, let's set a global variable to let hook_exit now it will have to run the indexer
global $update_node_index;
$update_node_index = $node;
break;
}
}
And that's it. I don't know if you have a better solution for this problem, but that works for me. Of course I did not change the code of your module, I just implement in my module the hook_nodeapi on update operation and then called node_load with reset=true.
I think Drupal's _node_index_node was not designed to be called right after an update operation, as instant search does.
Thanks :)
Comments
Comment #1
ru.meta CreditAttribution: ru.meta commentednode_load with cache reset working for me