Why does it need improved? Numerous errors get thrown because views_calc blindly takes the output of any view and then tries to theme it in theme.inc.
After getting the following error for various different views, I decided to start digging.

warning: Invalid argument supplied for foreach() in .../views_calc/theme.inc on line 180.

I am using the great noderelationships module, so I check its issue queue and found #598092: Using Views Calc module to display SUM. markus_petrux stated that views_calc handles the dynamic views generating differently from noderelationships. This led me to the code in views_calc_table.inc which executes the $summary_view and pushes the results to $this->view->totals without checking if there are any results.

Solution:
The patch that I am posting is based on noderelationships module's dynamic view executing code in noderelationships.pages.inc starting at line 133.

Results:
After applying the patch, all errors for line 180 have gone away AND I actually get totals displayed on my views_calc table in a node backreferenced view.

Comments

recrit’s picture

here is the patch

recrit’s picture

re-roll: in the new function added execute_summary_view, I had missed populating the array $this->view->sub_totals

recrit’s picture

after finding the missing subtotal fix in #2, I was confused as to why it was even running the subtotal query since my view did not exceed the items per page. The total rows get checked against the items per page in the theme.inc and outputs accordingly - subtotal, total OR just total. My thought is that is how it should be in the views query also... why run a query if you are not going to output it.

re-roll -2:
adds conditional check before executing the subtotal query:

$this->view->total_rows > $this->view->pager['items_per_page']
miro_dietiker’s picture

Status: Needs review » Needs work

This looks promising. However current code did change for some fixes.

Could you make a reroll?

miro_dietiker’s picture

Indeed the current preview() call adds large overhead and execute() is much better.
Regarding many other changes, i'm working on a much cleaner overhaul now which is based on your suggestions.

miro_dietiker’s picture

Status: Needs work » Fixed
StatusFileSize
new19.61 KB

Committed attached patch after a lot of work.

There's some minor doc fix with it and formatting corrections.
Due to the complete overhaul and amount of resulting work we cannot completely separate this all.

Hope you all agree on the current solution.
I've also eliminated the $$process part.

Please reopen if this huge commit broke something.

Status: Fixed » Closed (fixed)

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