Closed (won't fix)
Project:
Flag
Version:
6.x-1.3
Component:
Flag core
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
17 Dec 2010 at 21:36 UTC
Updated:
2 Jan 2011 at 09:29 UTC
flag.module: 6.1
line 332 if (isset($node->flag)) {
line 333 foreach ($node->flag as $name => $state) {
Should probably be something like:
line 332 if (!empty($node->flag) && is_array($node->flag)) {
line 333 foreach ($node->flag as $name => $state) {
Thanks,
Comments
Comment #1
mooffie commentedCould you explain why not checking for an array causes a problem?
Comment #2
draco2002 commentedThird party modules can access/modify the form array via form_alter hook and we use one that limits access to individual flags based on a users role.
I was getting reports of users with limited access getting the following warning:
“warning: Invalid argument supplied for foreach() in sites/all/modules/flag/flag.module on line 333.”
By modifying the code as mentioned in the report to verify that it is an array and has contents fixed this error. Granted it's a warning, but figured couldn't hurt to clean it up.
Comment #3
mooffie commentedI tried to reproduce the problem (by adding
'#access' => FALSEorunset()ing things in the form), but without success. I don't get a warning.What exactly do you do to the form in your hook_alter? It's possible that your code is buggy.
I won't add an is_array() check before understanding the problem. That's because when time comes to clean up our code, we'll have to investigate the reason for every expression, and this process takes a lot of time. I prefer to do this investigation right now.
We think alike. Let me know what your form_alter does.
Comment #4
mooffie commentedComment #5
mooffie commentedI got no response.
I'm marking this "wontfix". I believe the code the user uses is buggy.