Tagadelic warning on node view page
drupalina - April 10, 2008 - 17:43
| Project: | Community Tags |
| Version: | 6.x-1.0-beta1 |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | syh |
| Status: | active |
Jump to:
Description
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.

#1
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?
#2
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.
#3
Similar bug report
#4
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.
#5
I have this problem and I also have the community tags module installed. Any fixes available?
#6
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?
#7
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?
#8
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:
<?php
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?
#9
Yes, it's seems to be a bug related to the Community Tags module.
I will take a look and will provide a fix.
#10
#11
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.
#12
Automatically closed -- issue fixed for two weeks with no activity.
#13
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!
#14
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.
#15
Can you confirm that this is still valid in the 6.x-1.x release?
#16
subscribing
#17
Yes Dave; this is still valid in the 6.x-1.x release
#18
subscribing