I've started getting this error every now and then during my cron.php runs:

Invalid argument supplied for foreach() in /var/www/html/doadance/drupal/modules/taxonomy.module on line 1184.

The last module I installed was filemanager.

I have category module, taxonomy_access is activated, taxonomy wrapper not installed.

Any suggestions for resolving this, or is it a problem? Thanks.

-ron

Comments

florian’s picture

First check if your database has the tables for filemanager module. If it does, the only quick option I have is to delete the last module files. This must solve the issue for the moment.

Florian
The World is a big puzzle but not a solved one! - www.puzzle.ro

Florian

somebodysysop’s picture

The reason I installed filemanager was to be able to run Acidfree. So, I guess Acidfree was the actual last module I installed. I see file, file_revisions and files. Since everything worked, I will assume all the files are present.

I guess this isn't a big problem since it only occurs duing cron.php runs, I just don't know why it occurs. I'd hate to have to uninstall all my photos to see if the problem goes away (particularly if it doesn't).

Anyone seen this sort of behaviour before?

Sparky Marky’s picture

Yep, nearly always have it on mine, have you tried grabbing the latest version of the taxonomy.module??

You can pick up the latest Taxonomy module here - http://cvs.drupal.org/viewcvs/drupal/drupal/modules/

Just found out that my current errors from it were from a version of it left on the server by accident, so hopefully mine will work without problems now

Edit: Still happening....but only during the remote cron run, not if i run it manually :s

somebodysysop’s picture

Thanks. Will try that. It's not crucial since it doesn't happen all the time. But, it's a mystery, as as Captain Kirk would say, "Mysteries give me a bellyache".

Neil Adair’s picture

I'm getting the same bug with a clean Drupal 4.7.3 install with no contrib modules.

Johnny’s picture

I have just updated to 4.7.4 and was actually going to wait for the 5.0 release for my next update but this
pesky little error just wont go away just like the other posts it happens around when cron does its thing but also does it intermittently with a constant refer to this url http://www.therockymtnblog.com/node/feed
I have a handful of installed contributed modules but its seems in the core this problem exists.

Much hope the 5.0 upgrade will help this bug as it shows much promise. Regardless of all the little bugs of 4.7, it has been a need ed step forward that in turn has encourage much great development of the new 5.0.

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

I am still looking for a solution for this as waiting for a 5.0 upgrade might be a while for I don't know how far behind the contributors are with the work that is being done in core.

Kind Regards,
Johnny

plumbley’s picture

Taxonomy.module (in 4.7.4) tends to assume that $node->taxonomy always exists and is an array for any node. This should be true if the node has been loaded with node_load(), which calls hook_nodeapi('load',...) which will call taxonomy_nodeapi(...,'load',...) which sets $node->taxonomy to an array (empty if no items). But perhaps occasionally nodes get created that shortcut this, and they might end up without a taxonomy.

If $node->taxonomy is not set to an array, a couple of places in taxonomy.module will break. One is in taxonomy_node_update_index():

function taxonomy_node_update_index(&$node) {
  ... 
  foreach ($node->taxonomy as $term) {
    ...
  }
  ...
}

If $node->taxonomy is not set, this will give a Notice (probably ignored) and try to execute

  foreach (NULL as $term) {

which PHP will complain about. This is called during cron runs, which explains the cron error reports.

This has been fixed in taxonomy_link()

function taxonomy_link($type, $node = NULL) {
  ...
    if (array_key_exists('taxonomy', $node)) {
      foreach ($node->taxonomy as $term) {
        ...
      }
    }
   ...
}

so patching taxonomy_node_update_index() like this should fix it.

Another is in taxonomy_rss_item(), which explains the rss feed error. The same patch should fix this too. I can't see any others, though.

(If anyone fixes these successfully, please raise an issue with the fix - my locally modified version is a bit out of sync so I can't easily create and test a patch just at the moment)

Hope this helps,

Mark.
--
www.PostgraduateStudentships.co.uk - where ideas and funding meet

nicksanta’s picture

haha, funny to think this bug still exists on 6.10

I don't suppose a way to fix it would be to resave all the nodes?

----------------------
Nick Santamaria

nicksanta’s picture

This snippet didnt work... but short of adding a term to every node, what else is there to do? anyone?

<?php
$sql = "SELECT nid FROM node ORDER BY nid ASC";
$result = db_query($sql);
while ($nid = db_result($result)) {
  $node = node_load($nid);
  print 'saving '. $node->title ."\n";
  node_save($node);
}
?>

----------------------
Nick Santamaria