Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
if the the CCK field name is too long, the total fields are not displayed. In the views_calc_table_total
function the $totals object looks like this:
stdClass Object
(
[node_data_field_saco_title_field_saco_title_value] =>
[node_data_field_saco_title_field_saco_set_node_nid] =>
[node_data_field_common_list_price_field_common_list_price_va] =>
[SUM__node_data_field_common_list_price_field_common_list_pri] => 384767.00
[node_data_field_saco_title_field_saco_quantity_value] =>
[SUM__node_data_field_saco_title_field_saco_quantity_value] => 70
)
The totals are present, but the lookup variable $ext_alias
is set to
SUM__node_data_field_common_list_price_field_common_list_price_va
which fails to retreive the value from $totals.
Why are the variable names truncated to 61 characters?
/Kevin
Comment | File | Size | Author |
---|---|---|---|
#1 | workaround_for_truncated_variables-2011-05-20.patch | 523 bytes | kevin.mcnamee@mailbox.org |
Comments
Comment #1
kevin.mcnamee@mailbox.org CreditAttribution: kevin.mcnamee@mailbox.org commentedWorkaround for getting the totals displayed.
Comment #2
marcp CreditAttribution: marcp commentedJust ran into this and the patch appears to fix the bug, but I think it would be more accurate to fix the problem in the $totals array. I haven't delved in enough to see where things are getting truncated in there.
If there are two long field names that just differ past the 60th character, they'll get confused with this fix, right?
Comment #3
kevin.mcnamee@mailbox.org CreditAttribution: kevin.mcnamee@mailbox.org commentedRight. Note that I called the patch a "workaround"; it is not intended as a proper fix.
Comment #4
pvanerk CreditAttribution: pvanerk commentedThanks for your workaround. It works for me.
Comment #5
kevin.mcnamee@mailbox.org CreditAttribution: kevin.mcnamee@mailbox.org commentedThe problem seems to be related to how field aliases are created in the core Views module. The following line of code from views/plugins/views_plugin_query_default.inc line 691 are interesting
If I comment out this line and remove the workaround mentioned above, then the totals are displayed. Unfortunately, I can't make any sense of explanation in the code.
In general, this seems like a rather hasty patch that was created to solve a specific problem for Postgres. It does not take into account the resulting namespace collisions (i.e. truncating can result in duplicate field aliases) that can occur. This is evidenced by the still ongoing discussion on the same issue #571548: Identifiers longer than 63 characters are truncated, causing Views to break on Postgres. Several alternate patch solutions have been proposed, including one using 'MD5'ed aliases which looks promising.
/Kevin
Comment #6
Anonymous (not verified) CreditAttribution: Anonymous commentedOr if you're not using PostgreSQL, you can do as I did & undo the hasty change in Views that's causing this.
In views/plugins/views_plugin_query_default.inc:
Comment #7
KarenS CreditAttribution: KarenS commentedReported and fixed in another issue.
Comment #8
KarenS CreditAttribution: KarenS commented