After setting the view throws the following notice:

Notice: Undefined property: view::$row_index in views_handler_field->get_render_tokens() (line 1355 z /home/srv/www/site/sites/all/modules/views/handlers/views_handler_field.inc).

Notice: Undefined property: stdClass::$unknown in views_calc_table_total() (line 258 z /home/srv/www/site/sites/all/modules/views_calc/theme.inc).

Notice: Undefined property: stdClass::$unknown in views_calc_table_total() (line 258 z /home/srv/www/site/sites/all/modules/views_calc/theme.inc).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

KarenS’s picture

Status: Active » Postponed (maintainer needs more info)

Not enough information to reproduce the messages. I don't see these messages. Make sure you are using the very latest code. If you are, I need steps to reproduce on a clean install. In other words assume I have no idea what is in your view or what kind of fields you have set up and you have to explain to me exactly how you got to the place where you see this.

tregeagle’s picture

I had the same error and resolved it by ensuring the, "Link this field to the original piece of content" tickbox was cleared in the field that was being calculated.

rahimvirani’s picture

I have the same problem but cannot resolve.

1. enabled module
2. changed existing view from type table to views calc table
3. marked one field as sum in settings

result:

sum row with no amount and following error

Notice: Undefined property: view::$row_index in views_handler_field->get_render_tokens() (line 1355 of /var/www/gdt/sites/all/modules/views/handlers/views_handler_field.inc).
Notice: Undefined property: view::$row_index in views_handler_field->get_render_tokens() (line 1355 of /var/www/gdt/sites/all/modules/views/handlers/views_handler_field.inc).
Notice: Undefined property: view::$row_index in views_handler_field->get_render_tokens() (line 1355 of /var/www/gdt/sites/all/modules/views/handlers/views_handler_field.inc).
Notice: Undefined property: view::$row_index in views_handler_field->get_render_tokens() (line 1355 of /var/www/gdt/sites/all/modules/views/handlers/views_handler_field.inc).
Notice: Undefined property: view::$row_index in views_handler_field->get_render_tokens() (line 1355 of /var/www/gdt/sites/all/modules/views/handlers/views_handler_field.inc).
Notice: Undefined property: view::$row_index in views_handler_field->get_render_tokens() (line 1355 of /var/www/gdt/sites/all/modules/views/handlers/views_handler_field.inc).
Notice: Undefined property: stdClass::$users_field_data_field_beneficiary_uid in views_calc_table_total() (line 259 of /var/www/gdt/sites/all/modules/views_calc/theme.inc).
Notice: Undefined property: stdClass::$unknown in views_calc_table_total() (line 259 of /var/www/gdt/sites/all/modules/views_calc/theme.inc).
Notice: Undefined property: stdClass::$sum__field_data_field_request_amount_donation_request_entity_type in views_calc_table_total() (line 275 of /var/www/gdt/sites/all/modules/views_calc/theme.inc

rahimvirani’s picture

fixed my issues by

1. near line 270 in theme.inc, when ($field->aliases['entity_type']) is used, '_type' must be removed from value for ext_alias: $ext_alias = strtolower($calc) . '__' . str_replace("_type", "", $query_alias); This is because the member in the totals object does not have this suffix.
2. near line 260 in theme.inc, had to check if var is set before assignment: if(isset($totals->{$query_alias}))
$baserow->{$query_alias} = $totals->{$query_alias};
3. near line 312 in theme.inc, changed double var ref to single: $$decimal to $decimal.
4. near line 90 in theme.inc, had to set member ' $view->row_index = "";' as view requires it when using token vars.

dealancer’s picture

I have same issues. I am using it for in views for custom entity type.

lunk rat’s picture

I also have this issue, only on certain fields. I can't see what makes these fields different.

In my views_calc table, about 10 of 15 fields actually display total, and the rest raise the error.

The changes outlined in #4 solve most of my errors. But when I change this line (around 273-4):

$ext_alias = strtolower($calc) . '__' . $query_alias;

to this:

$ext_alias = strtolower($calc) . '__' . str_replace("_type", "", $query_alias);

Then the other 5 fields start displaying totals; however, now the previous 10 fileds (that worked before) are throwing the error and not totalling. So it's one or the other :(

I still don't know what triggers this. The only difference I can tell is that the fields that like $ext_alias = strtolower($calc) . '__' . str_replace("_type", "", $query_alias); have longer field names. Otherwise they seem to be exactly the same.

Ideas welcome.

lunk rat’s picture

I have confirmed that the difference between the fields that work and the fields that generate Notice: Undefined property: stdClass::$sum_field_name_blah is the number of characters in the system field_name: they can be up to 21 characters not including field_

Steps to reproduce:

Manually apply the edits outlined in #4.

Create a content type and add two fields with the following system names:
field_111111111111111111111 (21 characters after field_ )
field_1111111111111111111111 (22 characters after field_ )

Create a simple view with Views Calc table display plugin, add your fields and have views_calc perform a sum on them.

You will see something like the attached screenshot, where the 21 character field displays totals but the other two throw errors and display no totals.

I will try to fix and submit a patch, but I am not really sure why the character length is making a difference.

odegard’s picture

Status: Postponed (maintainer needs more info) » Active

I'm changing status to active, I've got further info on how to investigate this further thanks to lunk_rat.

Indeed it is the length of the field names that are the problem, and I've found a work around but it's far from ideal.

      $ext_alias = strtolower($calc) . '__' . $query_alias;
      if ($ext_alias == 'sum__field_data_field_abcdefghijklmnopqrstuvwx_node_entity_type') {
        $ext_alias = 'sum__field_data_field_abcdefghijklmnopqrstuvwx_node_entity_t';
      }
      if (in_array($field->field, $calc_fields)) {
        dsm($totals);
        $row->{$query_alias} = $totals->{$ext_alias};
      }

If you have devel you can use dsm to inspect the $totals variable around line 278. You will get a list of objects, inspect any of them and you will see something like this:

sum__field_data_field_abcdefghijklmn_node_entity_type (String, 2 characters ) 50 
sum__field_data_field_abcdefghijklmnopqrstu_node_entity_type (String, 3 characters ) 110 
sum__field_data_field_abcdefghijklmnopqrstuvwx_node_entity_t (String, 3 characters ) 100 

Notice the last line where the field name is truncated. I think this explains why #4 only works some times - when the field is exactly 5 bytes too long and not for any other case.

The quick and dirty work around is to check the $ext_alias for the(se) truncated field names and set the name to that in $totals (see above).

superspring’s picture

Status: Active » Needs review
FileSize
3.57 KB

This patch applies many fixes that were required to get aggregate summaries working on my site.
It includes the comments from #4 and #6.

kietnguyen’s picture

I manually patched the code since I have other patch from https://drupal.org/node/1570746 to display prefixes and suffixes for calculated row. Somehow, I don't need

$ext_alias = strtolower($calc) . '__' . str_replace("_type", "", $query_alias);

When I applied, my SUM didn't display... and I didn't add "Find which key in $totals is closest to the current" part.... The rest is working and fixes all my notices.

mojiro’s picture

Also 'Edit link' field causes the following messages

SQLSTATE[42000]: Syntax error or access violation: 1064 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 '= views_entity_node. WHERE (( (node.nid IN ('7951', '7946', '7944', '7942', '79' at line 18

SQLSTATE[42000]: Syntax error or access violation: 1064 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 '= views_entity_node. WHERE (( (node.status = '1') AND (node.type IN ('financial' at line 18

I do not know thow if this is being caused because I use percona mysql server

jurgenhaas’s picture

To me, what happened is that totals were added to the base object for each field, even for the unselected fields. All the rest seemed to be a follow-up error from there. A patch is attached which should resolve this.

jeremyheslop’s picture

In reference to the class names being to long I changed the theme.inc file to work for me. This is a quick hack and will fail if you have two long field names with the same beginning characters. This should work as long as your field names are less than 44 characters which will remove the node_entity_type appended at the end all together.

ie:
sum__field_data_field_abcdefghijklmnopqrstu_node_entity_type (27 character field name)
sum__field_data_field_abcdefghijklmnopqrstuvwx_node_entity_t (30 character field name, needs the hack)
sum__field_data_field_abcdefghijklmnopqrstuvwxyzabcdefghijkl (44 character field name, needs the hack and is max name to avoid duplicate entries)

I changed in theme.inc:

      $ext_alias = strtolower($calc) . '__' . $query_alias;
      if (in_array($field->field, $calc_fields)) {
              $row->{$query_alias} = $totals->{$ext_alias};
      }

to

      $ext_alias = strtolower($calc) . '__' . $query_alias;
      if(strlen($ext_alias) > 60) {
             $ext_alias  = substr($ext_alias, 0, 60);
      }
      if (in_array($field->field, $calc_fields)) {
              $row->{$query_alias} = $totals->{$ext_alias};
      }

I'm pretty sure this will work as long as field name (including field_) are less than 44 characters, but more testing is needed.

I also applied the changes above to get rid of the other errors I was having with $row_index.

Thanks to those who posted patches and code changes.

NOTE:
I tried the patch in http://drupal.org/node/1548552#comment-6862242 views_calc_aggregate_fix-1548552-9.patch but it gave a 0 total for me on the fields with long names.

a.milkovsky’s picture

FileSize
506 bytes

please review my patch too.
I added simple check for query_alias and it fixed issue for me.

about "view::$row_index" issue see http://drupal.org/node/1567108#comment-7026494

manuelBS’s picture

yes, this patch is neccessary and solves the issue

mwallace001’s picture

#13 worked for me!

czoperek’s picture

Version: 7.x-1.x-dev » 7.x-1.0
Component: Code » Documentation
Assigned: Unassigned » czoperek
Category: bug » feature
Priority: Normal » Critical
Status: Needs review » Active

I had a similar problem with errors, helped me patch: http://drupal.org/files/views_calc_aggregate_fix-1548552-9.patch thanks. view calc but still do not want to count, for example, the sum of the indicated fields

Stan Turyn’s picture

#14 patch works.

Taxoman’s picture

Component: Documentation » Code
Assigned: czoperek » Unassigned
Category: feature » bug
rsvelko’s picture

#14 works
and also the link in there to a patch works too

otcassetmgmt’s picture

I would like to install this patch, but I have never installed a patch? Do I simply copy this code and paste it somewhere?

froboy’s picture

jyee’s picture

Status: Active » Reviewed & tested by the community

patch in #14 is good.

jyee’s picture

Version: 7.x-1.0 » 7.x-1.x-dev
Priority: Critical » Normal
Norberto Ostallo’s picture

I confirm that patch #4 works fine.

Norberto Ostallo’s picture

Issue summary: View changes

Review

News4u’s picture

I applied #17 everything works fine but new error

Warning: number_format() expects parameter 1 to be double, string given in views_calc_table_total() (line 333 of /[path]/modules/views_calc/theme.inc).

I applied patch #17

News4u’s picture

Fixed.. totally
I rremoved all prefix/suffix in Global Math expression
If suffix/prefix is added ,, then problem arises

News4u’s picture

Suggestion ..
Views_calc module should be able to calculate/totaling Global Math expression column
Global Math expression only sum rows , so TOTAL SUM ROW should include the aggregate of all values in the Global Math expression column

News4u’s picture

Suggestion ..
Views_calc module should be able to calculate/totaling Global Math expression column
Global Math expression only sum rows , so TOTAL SUM ROW should include the aggregate of all values in the Global Math expression column

KarenS’s picture

Issue summary: View changes

There is another issue about prefix suffix creating problems, there is another issue about the edit link, and the notices should be fixed in dev now.

KarenS’s picture

Status: Reviewed & tested by the community » Closed (duplicate)