In recent days I noticed that I keep getting this error
warning: Invalid argument supplied for foreach() in /home/sitename/public_html/sitename/sites/all/modules/tagadelic/tagadelic.module on line 285.

I often get it on aggregator pages.

also, I run a multilingual site with 3 enabled languages. (could it be a glitch related to taxonomies?)
I tend to get this error message more often, if not ONLY, when I submit content in the non-default language.

I've googled for this problem, but it looks like there are only 2 sites that seem to have it.

Comments

Bèr Kessels’s picture

Status: Active » Postponed (maintainer needs more info)

the functioncall theme('tagadelic_weighted', $terms), must always receive an array. It seems you are passing it invalid information. Did you install any 3rdparty tagadelic modules, or created any custom php blocks with tags?

drupalina’s picture

I'm not a programmer or coder (I just put modules together and hope that they will work together). Could you please explain what you mean in more detail.

I use Drigg module. And also Community Tags module -- these are the only modules that I can think of that might be related to Tagadelic.

The strange thing is that this error is displayed only to the Anonymous (logged out) readers. When user is logged in, he cannot see it.

Note: in my settings, Anonymous users can create some content types. Could that be a factor???

I have also noticed that this problem does not occur for all the nodes -- ONLY FOR THOSE NODES WHICH WERE CREATED BY ANONYMOUS USERS. I strongly suspect that this is where the problem is, but it is essential the the nature of my site that content is submitted anonymously.

pfaocle’s picture

drupalina’s picture

Yeah, there seems to be some strange incompatibility between Community Tags module and the Tagadelic (see also http://drupal.org/node/262119), even though Community Tags uses Tagadelic as a required module.

deverman’s picture

I have this problem and I also have the community tags module installed. Any fixes available?

alex-and-r’s picture

And I have the same when I'm viewing nodes under anonymous user.

My scenario is like this:
When I'm logged in everything is OK.
When I'm not logged and I am anonymous I can view nodes the same way (means no errors). But when I tag a node after that I see it only with that "Invalid argument supplied for foreach().." error and in place of tagging form I have "You have already tagged this post. Your tags:" so I can't tag this node naymore.

I believe there is some problem with anonymous user and this module!

So any suggestions how to fix it?

alex-and-r’s picture

So, still no activity? Ok, let me show what I think.

I think it's a problem of Community_tags module and not Tagadelic. The first depends on the latter and on some points calls for functions from Tagadelic.
And now to what I found. Community_tags module (to be specific - "community_tags.module,v 1.32.2.6 2008/02/19 10:59:22") calls "theme_community_tags" function on lines #229 and #670 of community_tags.module file. And this "theme_community_tags" function in turn calls Tagadelic function "theme_tagadelic_weighted" (exactly THE function where the error on line #285 occurs).

But on line #229 the call for "theme_community_tags" function is like this:

theme('community_tags', 'user_node', NULL, $user->uid, $node->nid)

while on line #670 the call is different:

theme('community_tags', $sorted_tags)

And if we look at the "theme_community_tags" function definition we see the following:

function theme_community_tags($tags)

So I believe the first call on line #229 of community_tags.module is incorrect or am I not right? And since incorrect argument is passed to "theme_community_tags" function the same incorrect argument is passed down to Tagadelic "theme_tagadelic_weighted" function and we receive an error.

Any comments?

May be I should post it in community_tags issues?

pfaocle’s picture

Status: Postponed (maintainer needs more info) » Active

Your reasoning seems correct - the string 'user_node' is passed, via theme_community_tags, to theme_tagadelic_weighted(), which expects an array as its first parameter.

The call on line #229 of community_tags.module does look incorrect, but perhaps theme_tagadelic_weighted() should do a quick check on its parameter? Eg:

function theme_tagadelic_weighted($terms) {
  if (count($terms) > 0) {
    foreach ($terms as $term) {
      $output .= l($term->name, taxonomy_term_path($term), array('class' => "tagadelic level$term->weight", 'rel' => 'tag')) ." \n";
    }
  }

  return $output;
}

If not, bump this issue from this queue into the Community Tags queue, rather than open a new issue?

dropcube’s picture

Project: Tagadelic » Community Tags
Version: 5.x-1.0 » 5.x-1.x-dev
Assigned: Unassigned » dropcube
Priority: Normal » Critical

Yes, it's seems to be a bug related to the Community Tags module.

I will take a look and will provide a fix.

dropcube’s picture

Title: Invalid argument supplied for foreach() » Tagadelic warning on node view page
dropcube’s picture

Status: Active » Fixed

Ok, I found a patch with a quick fix for this: #216853: Bad call to theme_community_tags causes error. However, a revamp to community_tags_node_view() is still is required.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

drupalina’s picture

Version: 5.x-1.x-dev » 5.x-1.0-beta1
Status: Closed (fixed) » Active

How come this issue was automatically closed??? I'm using the 5x-1.0-beta1 and I'm still having these problems.

I'm reopening this issue and marking it under version 5x-1.0-beta1.

Please let us know what's the current status on this issue. Was this patch tested? Did it work? Was it committed to .dev version?

Thanks!

tierecke’s picture

Version: 5.x-1.0-beta1 » 6.x-1.0-beta1

I have it too with v6. After adding tags I get:

warning: Invalid argument supplied for foreach() in /srv/www/htdocs/sites/my.gemeentemuseum.nl.exp/modules/tagadelic/tagadelic.module on line 309.

And I can't see/edit my tags anymore.

dave reid’s picture

Status: Active » Postponed (maintainer needs more info)

Can you confirm that this is still valid in the 6.x-1.x release?

XerraX’s picture

subscribing

syh’s picture

Assigned: dropcube » syh
Status: Postponed (maintainer needs more info) » Active

Yes Dave; this is still valid in the 6.x-1.x release

Drupalized’s picture

subscribing

chaps2’s picture

Status: Active » Fixed

I've tried quite hard to reproduce this bug and can't. It hasn't been reported for nearly 2 years so I'm marking as fixed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.