Handling files which are not attached to nodes

ehart - August 6, 2008 - 16:09
Project:Swish-E Indexer
Version:5.x-1.1
Component:Code
Category:bug report
Priority:minor
Assigned:Unassigned
Status:needs review
Description

There is a case where swish finds files which are not associated with any node. This causes php warnings.

Original (lines 113-114):

$snippet = search_excerpt($keys,$text_item->fulltext);
$find[] = array('link' => $link, 'title' => $title, 'snippet' => $snippet, 'extra' => $extra, 'node' => node_load($text_item->nid));

Fix:

if($text_item){
  $snippet = search_excerpt($keys,$text_item->fulltext);
  $find[] = array('link' => $link, 'title' => $title, 'snippet' => $snippet, 'extra' => $extra, 'node' => node_load($text_item->nid));
}

(Sorry, I don't know how to make this into a patch)

 
 

Drupal is a registered trademark of Dries Buytaert.