There's a weird little problem with the data that node.module provides the data for the "99% of the site has been indexed. There is 1 item left to index." status message on /admin/settings/search, i.e. the node_search function, it does not take into account that some content types can be flagged to not be indexed. This patch fixes this problem so that only content of a type configured to be indexed gets considered for the calculations.
FYI the revision number is from our internal SCM rather than being against trunk. Further, the code comes from #146466: D6 search refactoring (backport to 5) rather than directly from D6.
Index: modules/node/node.module
===================================================================
--- modules/node/node.module (revision 668)
+++ modules/node/node.module (working copy)
@@ -859,9 +859,18 @@
return;
case 'status':
- $total = db_result(db_query('SELECT COUNT(*) FROM {node} WHERE status = 1'));
- $remaining = db_result(db_query("SELECT COUNT(*) FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE n.status = 1 AND (d.sid IS NULL OR d.reindex > 0)"));
- $pending = db_result(db_query("SELECT COUNT(*) FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE n.status = 1 AND d.reindex < 0"));
+ // see if some of the types have been disabled
+ $types = variable_get('search_config_disable_index_type', '');
+ if(is_array($types) && count($types) > 0) {
+ foreach($types as $i => $type)
+ $types[$i] = "'{$type}'";
+ $types = " AND n.type NOT IN (" . implode(',', $types) .")";
+ }
+ else
+ $types = '';
+ $total = db_result(db_query('SELECT COUNT(*) FROM {node} WHERE status = 1'.$types));
+ $remaining = db_result(db_query("SELECT COUNT(*) FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE n.status = 1 AND (d.sid IS NULL OR d.reindex > 0)".$types));
+ $pending = db_result(db_query("SELECT COUNT(*) FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE n.status = 1 AND d.reindex < 0".$types));
return array('remaining' => $remaining, 'total' => $total, 'pending' => $pending);
case 'admin':
Comments
Comment #1
DamienMcKennaIf I get time I'll try to create a patch against 6.x-dev, but I can't guarantee an ETA.
Comment #2
douggreen CreditAttribution: douggreen commentedIs the search_config_disable_index_type set in a contrib module? I can't find it in core. If this is set in a contrib module, then it's that contrib module that's going to have to implement the fix.
Comment #3
DamienMcKennadouggreen,
Oh my, you're right, I thought it was part of core. Doh. It actually comes from search_config, and I've updated the task details accordingly. Thanks for spotting that.
Comment #4
arhak CreditAttribution: arhak commentedsubscribing
Comment #5
canen CreditAttribution: canen commentedFrom some quick testing I can't seem to reproduce this in Drupal 5. The indexing report seems to work fine with some content types removed from the index.
I am using a minimal install, with just two content types, for testing so that may have something to do with it. I think the patch you applied may be more of an issue though. Can you test with an un-patched node module and see if you have the same issue?
Comment #6
canen CreditAttribution: canen commented