warning: Invalid argument supplied for foreach() in /views_calc/theme.inc on line 180
Ashford - May 7, 2009 - 00:06
| Project: | Views Calc |
| Version: | 6.x-1.3 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | duplicate |
Jump to:
Description
warning: Invalid argument supplied for foreach() in /views_calc/theme.inc on line 180
The Views preview will display as a Style: Table. I get the error message shown above when I edit the Style to a Views Calc Table.
Drupal 6.11
CCK 6.x-2.2
Views 6.x-2.5
Views Calc 6.x-1.2

#1
Getting the same error, but on line 178 rather than line 180.
D6.9
Views 2.5
Views Calc 1.2
CCK 2.1
The error message appears even on the simplest views: a list of nodes showing only the nid, for example. It shows up as soon as the table style is switched to Views Calc from Table, even if I haven't done any calculations.
What makes me think it's a minor bug is that as soon as you switch on some kind of calculation, the error seems to disappear. From looking at the code it seems that the error arises when an array is not set which makes sense.
#2
Whoops, changed the title in an unhelpful way!
#3
Hey, Jim. Thanks for responding. I go into anxiety mode when I'm the only one with the problem. Makes me think I've just done something really stupid and the Great Drupal Kahuna is standing behind the screen laughing too hard to answer me.
My error line was different maybe because I did have the info you said was missing in your situation? I did have columns with Decimal values and had selected SUM as the calculation.
What are we missing that all the other Views_Calc users have already figured out?
#4
I am getting this error too (warning: Invalid argument supplied for foreach () in /modules/views_calc/theme.inc on line 178 or sometimes 180), as well as very strange multiplicative math errors. When a filter on a view returns 1 node, views_calc returns a count of 5 and the sum of an integer CCK field is n * 5 (where n is the correct sum of the CCK field) . In another view, when it returns 1 node, the count is 2 and the sum of a float CCK field is n * 2. Anyone have any ideas on this?
I suspect it may have something to do with 'Relationships' based on what I see in the documentation. I am using modules like Node Refferer and my views tend to have fields which are links to other nodes. Perhaps when they say that views_calc is not Relationships-safe it means that these links can't be used in a view?
I am using Drupal 6.11, Views 6.x-2.5, CCK 6.x-2.2, Node Referrer 6.x-1.x-dev, ....
#5
Bingo! I was using the Relationship setting also. I had to have gotten the idea from following a tutorial; otherwise, I wouldn't have known what Relationship was used for at all.
When I remove the Relationship from the View, I can get the results I want by finessing the Argument settings.
#6
Right, this is the known issue that relationships don't work.
#7
Hi, I just want to say that In my view I do not use any relationships and the problem still occurs also followed by another one in SQL query.
This issue is definitely not fixed.
Cheers,
K.
#8
I´ve got this error too in a clean 6.12 install, without arguments nor relationships...
PLUS that, I got this other error too:
user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DISTINCT(node.nid), SUM(node_data_field_monto_total.field_monto_total_value) ' at line 3 query: SELECT MAX('') AS node_title, MAX('SUM') AS TOTAL_SUM, MAX('') AS DISTINCT(node.nid), SUM(node_data_field_monto_total.field_monto_total_value) AS node_data_field_monto_total_field_monto_total_value FROM node node LEFT JOIN content_type_calculos node_data_field_monto_total ON node.vid = node_data_field_monto_total.vid WHERE node.type in ('calculos') in C:\xampplite\htdocs\drupal610\sites\all\modules\views\includes\view.inc on line 735.#9
I´m sorry, but as this error appears on a clean install and prevents us to use the module, I´m setting this as a bug, and a critical one.
Is there any workaround...?
Thanks!
#10
Not enough information for me to do anything. I have no idea what your view looks like or if you are using custom fields, and if so, what they look like, or anything else remotely useful. I need an export of your view. If you are using custom Views Calc fields in your view, I need to see what how they are set up.
I do not get this error in any of my views, so there is something different in your setup. Also make sure you are using the latest code, this issue says it is for version 1.2, which is not the latest code.
#11
Thanks Karen!
I´m gonna try out the latest version and see what happens. If the error is still there I´ll print here an export of my view.
Rosamunda
#12
This issue is probably a consequence of #510754: Calculations are made against the default display regardless of actual display. Marking as duplicate for now; if this is still unresolved after patching, feel free to change the status back.
#13
I have been seeing this error as a result of using a view that uses "views calc table" as the default setting. In one block I had only one field visible, the node title, meaning no calculations had to be made. This appears to be what created the error on my site.
As a workaround, I selected "override" on the block view, switched it to "table" and configured those settings accordingly. It appears to happen when views calc has no data to process.
After solving this on my own re-reading #1 makes a lot more sense. It would be nice if this module caught this error and displayed a sensible message that would remind people to switch back to "table" layout for that page or block.
Thanks for this module, it has been very useful to me.
#14
This can also be a role permissions problem. For example, I have a view that sums the values of two fields. If the user trying to display the view is not a member of a role having permission to view both of the fields then they will get:
warning: Invalid argument supplied for foreach() in /views_calc/theme.inc on line 178
If one of the field's view permission is set they won't get the error but will only see the field they have permission for. Bottom line is that as Ryan Weal pointed out if there is no calculation to perform then you will get the error.