division by zero in node_search
catch - June 25, 2008 - 12:00
| Project: | xapian |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
Now xapian is indexing, and search is working, I'm getting a lot of division by zero errors in node_search:
This is the relevant bit of code:
$results[] = array('link' => url('node/'. $item->sid, NULL, NULL, TRUE),
'type' => node_get_types('name', $node),
'title' => $node->title,
'user' => theme('username', $node),
'date' => $node->changed,
'node' => $node,
'extra' => $extra,
'score' => $item->score / $total,
'snippet' => search_excerpt($keys, $node->body));Marking as active needs more info until I can track down steps to reproduce.

#1
When do you see these errors? Where do they show up? (In the watchdog log? On the screen?)
#2
Sorry, forgot to follow up on this one.
Errors are in watchdog.
The division by zero happens when all node scoring factors are set to 0 - so it just needs to check for that condition (ref: http://acquia.com/blog/drupals-search-compared-google-and-yahoo for how core handles this and why I did it in the first place).
#3
What is the complete error message?
#4
Division by zero in modules/node/node.module on line 948.
#5
If you disable the xapian module, does the error go away? Offhand, it seems unlikely that the xapian module is responsible for the error you're seeing, as it's not using core's weighting methods.
#6
Yep, same issue without xapian enabled. Sorry. Idiotic bug report.
#7
Core bug here for reference: http://drupal.org/node/252580 Looks like it never made it into D5.