Duuring every few cron runs, I get the following error 3 times in the log:

Invalid argument supplied for foreach() in /home/example/public_html/modules/taxonomy.module on line 1199.

The foreach line is in this function:

/**
 * Implementation of hook_nodeapi('update_index').
 */
function taxonomy_node_update_index(&$node) {
  $output = array();
  foreach ($node->taxonomy as $term) {
    $output[] = $term->name;
  }
  if (count($output)) {
    return '<strong>('. implode(', ', $output) .')</strong>';
  }
}

Running drupal 4.7.0, mySQL 4.0.25, PHP Version 4.4.1. Note, however, site was originally created using drupal 4.7beta and then updated to 4.7.0.

Any suggestions as to how to solve/troubleshoot the problem? I'm guessing there are some invalid entries in the node or taxonomy database tables.

Comments

pwolanin’s picture

trying to find invalid or orpahn entries, I ran this query:

SELECT sd.* FROM search_dataset sd LEFT JOIN node n ON n.nid=sd.sid WHERE n.nid is NULL

The only result is the following table row:

"sid";"type";"data"
"0";"node";" n a "

Should there be an sid=0 row in the search_dataset table?

---
Work: BioRAFT

pwolanin’s picture

..after I had the search module re-index all content.

---
Work: BioRAFT

ac’s picture

I have the same problem. Not sure what it is. Didnt happen in 4.6 but after upgrade i get this. Like you said its not everytime cron runs but it is every few hours
------------------------------
Alex Cochrane
Spoon Media

pwolanin’s picture

Somone posted an issue claming this problem was related to OG access control: http://drupal.org/node/64333

---
Work: BioRAFT

ac’s picture

I dont have OG running on this instance
------------------------------
Alex Cochrane
Spoon Media

Mikey_R’s picture

I have been getting 15 errors { Invalid argument supplied for foreach() in "mysite"/modules/taxonomy.module on line 1197} each time my cron ran. I was using poormans cron module and thought it was that so I eventually got around to updating my crontab, but it was still appearing. I have disabled node_privacy_byrole.module and the errors have gone away.

When the module is enabled the site was / is fine the search works and everything can be viewed by the correct groups, I just got a fistfull of php errors in the logs. As the site works I am not too bothered, but my client does have access to the logs so I would prefer if if the errors were not there!

I have also noticed that the search page tells me that the site is 0% indexed, I have pressed the reindex button, run cron.php but it never moves..

Any ideas on any of this?

pwolanin’s picture

No, only OG. But maybe this points to a problem with access control modules in general.

---
Work: BioRAFT

ac’s picture

Yes i am running node privacy byrole on this site. Looks like its an access control problem
------------------------------
Alex Cochrane
Spoon Media

calebtr’s picture

I'm getting this error when I run cron and, in adding to the search index, add a node that been assigned any taxonomy terms, which in my case is a lot of nodes.

I guessed that $node->taxonomy isn't returning an array and was able to get the error to stop. I am pretty sure that things are being indexed properly.

This may or may not be the right tree to bark up:

function taxonomy_node_update_index(&$node) {
  $output = array();
  if ($node->taxonomy) {
  foreach ($node->taxonomy as $term) {
    $output[] = $term->name;
  }
  if (count($output)) {
    return '<strong>('. implode(', ', $output) .')</strong>';
  }
 }
  return;
}

kyouens’s picture

I would like to bump this post and find out whether anyone has successfully fixed this issue or knows whether it's being addressed in CVS? I'm running taxonomy_access and have the same problem. I do know about this issue which proposes a patch, but I'm trying not to modify core so I don't think I'll apply it.

http://drupal.org/node/71882

Thanks.

pwolanin’s picture

A different error now...

The above error may have been partially solved by this patch:

http://drupal.org/node/64857

I'm sometimes getting a different error now:

Message Invalid argument supplied for foreach() in /home/site/public_html/modules/taxonomy.module on line 1184.

---
Work: BioRAFT

ac’s picture

Your patch completely fixed this for me. Havent seen this error since patching

------------------------------
Alex Cochrane
Spoon Media