Quantcast
Channel: How to find bad PHP node that makes search_cron fail? - Drupal Answers
Viewing all articles
Browse latest Browse all 5

Answer by Chaulky for How to find bad PHP node that makes search_cron fail?

$
0
0

The function db_fetch_object() doesn't exist in Drupal 7, it was replaced by the new Database API. Checkout Dynamic Querys, Ranges and limits or even Static querys for more details.

In this specific case, you don't need to write nearly as much code. This function that thread suggests editing, node_update_index(), looks like this in Drupal 7.

function node_update_index() {   $limit = (int)variable_get('search_cron_limit', 100);   $result = db_query_range("SELECT n.nid FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE d.sid IS NULL OR d.reindex <> 0 ORDER BY d.reindex ASC, n.nid ASC", 0, $limit, array(), array('target' => 'slave'));   foreach ($result as $node) {     _node_index_node($node);   }}

According to that thread, you just want to store the nid of the nodes as they are indexed so you can tell which one is causing the problem. To do that, you just need to add the call to watchdog() in the foreach loop, like so...

function node_update_index() {   $limit = (int)variable_get('search_cron_limit', 100);   $result = db_query_range("SELECT n.nid FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE d.sid IS NULL OR d.reindex <> 0 ORDER BY d.reindex ASC, n.nid ASC", 0, $limit, array(), array('target' => 'slave'));   foreach ($result as $node) {     watchdog('cron', "about to index node " . $node->nid);   /// ADD THIS TO DEBUG     _node_index_node($node);   }}

Viewing all articles
Browse latest Browse all 5

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>