The node_update_index() function seems to do a mini-version of node_view() without running the final result through theme_node(). However, node_view() invokes node_invoke_nodeapi($node, 'alter', $teaser, $page); and node_update_index() does not. This means that modules that alter the display of a node body in all other cases (*cough* ConTemplate *cough*) will NOT alter the body during the indexing process. More simply, the search engine is not indexing what the user sees on the page.

This patch adds node_invoke_nodeapi($node, 'alter'); into node_update_index() in order to remedy this situation.

This is also a D5 bug and should be backported.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

greggles’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
214 bytes

I was able to repeat this bug and the patch solved the problem.

Steps for me to repeat:

1. create a demo module which alters the the content (see attached for trivial example)
2. Enable search and visit cron.php to index the site
3. search for content added by the alter (e.g. weasel)
Actual restuls: weasel is not found

To test the fix be sure to visit admin/settings/search and click re-index site and re-visit cron.php

The only question I *might* have is if this is a performance problem, but I don't think that's a real problem since search _is_ already doing a lot of work and is already scalable.

So, I'm marking as RTBC.

jjeff’s picture

Thanks Greg! re: performance, there is certainly always potential for abuse but technically we've still got less overhead than node_view(). And there are still very few modules that implement 'alter'.

Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Looks good, thanks! Committed.

jjeff’s picture

Version: 6.x-dev » 5.x-dev
Status: Fixed » Patch (to be ported)

This problem exists in D5 as well.

Haven't tested, but patch will most likely apply.

drumm’s picture

Status: Patch (to be ported) » Fixed

Committed to 5.x.

IIRC, we added this in 5.x, so no need to 4.7.x.

Anonymous’s picture

Status: Fixed » Closed (fixed)