I've got a content type that has a state selection dropdown field, and I'd like to get a list of all selected values.

When I turn on aggregation on that field, I get no results and dozens of errors like these:

Notice: Trying to get property of non-object in entity_extract_ids() (line 7368 of /home/domains/alaa/www/includes/common.inc).
Notice: Undefined index: field_name in field_language() (line 275 of /home/domains/alaa/www/modules/field/field.multilingual.inc).
Notice: Undefined index: in _field_invoke_multiple() (line 299 of /home/domains/alaa/www/modules/field/field.attach.inc).

This is the query that it's trying to run:

SELECT field_data_field_state.field_state_value AS field_data_field_state_field_state_value, MIN(node.nid) AS nid, 'node' AS field_data_field_state_node_entity_type
FROM 
{node} node
LEFT JOIN {field_data_field_state} field_data_field_state ON node.nid = field_data_field_state.entity_id AND (field_data_field_state.entity_type = node AND field_data_field_state.deleted = 0)
WHERE (( (node.status = '1') AND (node.type IN  ('allergist')) ))
GROUP BY field_data_field_state_field_state_value
ORDER BY field_data_field_state_field_state_value ASC

I'm not sure if this is just something that Views is showing funny, but if I run that query directly, I get the correct results, but only if I add quotes around 'node' in the join on field_data_field_state.entity_type = node.

Comments

mradcliffe’s picture

I got these warnings under the following scenario as well:

Non-content view (custom entity) with content relationship
Aggregate true
Node field with aggregate group column set to "value" and not "entity id".

In my case, I was not actually using the that field's value, so I switched it to entity id and the warnings were no longer triggered. I also tried adding a field from a custom entity, and that did not trigger the error when aggregation group column was set to "value".

Hope this helps track it down.

karlshea’s picture

I am not using a custom entity, just a normal content type.

The aggregate group column is set to "value" however, and I do need to use the value. When I set it to "entity id" it no longer throws the error, but I don't get the results that I need.

At least I have a confirmation though :-)

mradcliffe’s picture

Still valid for Drupal 7.4.

mradcliffe’s picture

A body text field generates the following warnings when aggregate settings set to value for that field.

	Notice: Undefined index: format in _text_sanitize() (line 319 of modules/field/modules/text/text.module).
	Notice: Undefined index: format in _text_sanitize() (line 319 of modules/field/modules/text/text.module).

I tried a date field on another site with date 7.x-2.x-dev, and I did not witness any warnings.

I'm trying to come up with a test view that demonstrates everything without being too customized.

mradcliffe’s picture

The initial issue was fixed in #1194900: Missing values with aggregation sum, avg, min, max (patch included) on June 28th, commit f9af377bfcdd19d3a047d76d956a1871e1c0aed3.

The _text_sanitize issue was introduced in that commit.

Open that issue and close this one? Or keep this one open?

mradcliffe’s picture

Component: Miscellaneous » fieldapi data
Priority: Normal » Minor

$this->options['group_columns'] needs to have appropriate columns set as default to fix the text field issues.

Fixed by including format in group columns. That should have been obvious. Crap.

dawehner’s picture

Status: Active » Fixed

If the initial part of the issue is solved, it nearly all the times helps to create a new issue.

Less comments etc. Thanks!

Rob_Feature’s picture

Created an issue for _text_sanitize over at #1219054: Undefined index: format in _text_sanitize()

Status: Fixed » Closed (fixed)

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

reg’s picture

I added a field to the content type (articles) and because I had aggregation on I got lots of errors.

Then I added it to views (field area) and it went away, then I deleted it and the errors returned.

Sorry I don't have more information, still working on it.