I upgraded from 4.6 to 4.7.1 (using MySQL 5.0.19) and could not successfully perform search. ReIndexing and rerunning the cron didn't help .. Following are the changes I made to get the new version working.
a) Actually the cron job would end in a CGI /Fast CGi crash for some reason or after the cron finished there would be messages in watchdog indicating "foreach ($node->taxonomy as $term) {" in "taxonomy_node_update_index". For some reason "$node->taxonomy" was not an array; placing an "if" condition before the "For" loop solved this.
function taxonomy_node_update_index(&$node) {
$output = array();
if ($node->taxonomy) { //*IP Added the "If" check
foreach ($node->taxonomy as $term) {
$output[] = $term->name;
}
}
if (count($output)) {
return '<strong>('. implode(', ', $output) .')</strong>';
}
}
b) Still the cron jobs would never update the "%" of complete indices. In "node_update_index()" "$last" is extracted from "variable_get('node_cron_last', 0)" .. this should actually be "$last_changed" as following:
$last_change = variable_get('node_cron_last', 0); //*IP+1 changed $last->$last_change
$last = $last_change;
Next the SQL query does a "GREATEST" operation which will return a NULL value if either of the values are null (this is true as of MySQL version 5.0.13). So I changed the query to return "n.changed" value as well and later inside the "while" loop I used that value. The SQl query also had an extra "$last" argument being passed.
$result = db_query_range('SELECT GREATEST(c.last_comment_timestamp, n.changed) as last_change, n.changed as nodeChanged, n.nid FROM {node} n LEFT JOIN {node_comment_statistics} c ON n.nid = c.nid WHERE n.status = 1 AND ((GREATEST(n.changed, c.last_comment_timestamp) = %d AND n.nid > %d) OR (n.changed > %d OR c.last_comment_timestamp > %d)) ORDER BY GREATEST(n.changed, c.last_comment_timestamp) ASC, n.nid ASC', $last, $last_nid, $last, $last, 0, $limit);
//*IP-1 removed an extra $last in the above statement and returning n.changed
while ($node = db_fetch_object($result)) {
if (!$node->last_change) { //*IP+2 Check to handle NULL value from GREATEST operation
$node->last_change = $node->nodeChanged;
}
$last_change = $node->last_change;
Since "$last_change" is getting set from "$node->last_change" so a NULL value would cause that to become NULL which would cause nothing to be saved in "node_update_shutdown". As a result of this the indexing was always "0%" and so every cron run would just index the first 100 nodes over and over again.
Comments
Comment #1
Thomas Sewell commentedCan we get a patch to test that has these changes in it. I confess that I'm having a hard time finding all the modifications listed above to attempt to apply them manually.
Comment #2
Thomas Sewell commentedFor those having this problem because they've manually imported content into the node and/or node_revisions tables, the php code in http://drupal.org/node/50151#comment-137637 creates the necessary entries in node_comment_statistics (even for nodes with no comments and comments disabled), which also avoids the problem of the SELECT GREATEST returning a NULL value.
Comment #3
magico commentedAnyone else with this problem?
Comment #4
gawan commentedA few weeks I haven't set up cron.php script running. Than a had more "1000 items left to index." And than after I tried running cron.php nothing changed and when I tried to search I got no result. And this hack help me.
I was despareted I searched this solution more than 1 day....
But when I try to re-index in admin/settings/search
than a get "0% of the site has been indexed. There are 1135 items left to index." again.
This button still not working corretly.
(I use ubuntu dapper with default LAMP configuration)
Comment #5
ajk commentedDoes the information on this issue help anyone? If so, report back here and I'll look into it some more
http://drupal.org/node/57106
Comment #6
magico commentedAccording to previous issue.
Comment #7
(not verified) commented