The gigantic and amazing patch to the search module that was committed over at http://drupal.org/node/146466 does wonderful things, but I found a small bug. It does not correctly handle the situation where one node links to another and then that link gets changed -- the old link will remain in the search index as a "ghost" and continue to show up in search results (even after cron has been run a couple times to update the search index).
After poking around a bit, I found that this was due to a simple PHP mistake. The following code is used in search_index():
// Any left-over links in $links no longer exist. Delete them and mark the nodes for reindexing.
foreach ($links as $nid) {
db_query("DELETE FROM {search_node_links} WHERE sid = %d AND type = '%s' AND nid = %d", $sid, $type, $nid);
search_touch_node($nid);
}
However, the nid is actually the key of the $links array, not its value. Therefore, changing the first line to foreach ($links as $nid => $leftover_caption) {
fixes the problem.
A patch is attached.
Comment | File | Size | Author |
---|---|---|---|
#1 | 205199.patch | 742 bytes | douggreen |
search_update_links.patch | 751 bytes | David_Rothstein | |
Comments
Comment #1
douggreen CreditAttribution: douggreen commentedThanks! I reviewed the code and confirm that this is a bug. I also applied the patch and confirm that it applies. I changed the variable name from "leftover_caption" to just "caption", under the guise, that they're all leftover -- you could equally rename "nid" to "leftover_nid".
Comment #2
Gábor HojtsyThanks, committed.
Comment #3
(not verified) CreditAttribution: commentedAutomatically closed -- issue fixed for two weeks with no activity.