node_load() does a query with "FROM {node} n INNER JOIN {users} u ON u.uid = n.uid".
As a consequence, it will return FALSE if the node author does not exist.
_node_update_index() does not check if node_load() was successful.
-----
Why is this a problem?
Tried this on D6:
drush cron
Invalid argument supplied for foreach() in ../taxonomy.module
stack trace:
- taxonomy_node_update_index(&$node)
- taxonomy_nodeapi()
- node_invoke_nodeapi()
- _node_index_node()
- node_update_index()
- module_invoke('node', 'update_index')
- search_cron()
The problem begins when node_update_index() does this query:
"SELECT n.nid FROM {node} n ..."
with no check if the author exists or not.
Then _node_update_index() calls node_load(), which returns FALSE.
Then _node_update_index() does $node->build_mode = NODE_BUILD_SEARCH_INDEX;, which turns the FALSE value into an object (with only one attribute).
Then _node_update_index() calls node_build_content() and node_invoke_nodeapi(), with a node that does not exist.
-----
I'm not sure whether this has to be fixed in node_load() or in _node_update_index(),
or if the database is considered broken if a node author does not exist.
Comments
Comment #1
donquixote commentedD7 uses NodeController::load() instead of node_load(), and I have not checked if this has the same effect.
Comment #3
jwilson3I hit this issue on a legacy drupal 6 site. had to write a drush script to fix it. YMMV.