I'm getting a ton of these on a view page:

Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 188 of includes/entity.inc). Backtrace:

array_flip(Array) entity.inc:188
DrupalDefaultEntityController->load(Array, Array) common.inc:7623
entity_load('taxonomy_term', Array) relation_entity_collector.module:457
relation_entity_collector_views_post_execute(Object) view.inc:1108
view->execute(NULL) view.inc:1118
view->render() views_plugin_display_page.inc:224
views_plugin_display_page->execute() view.inc:1244
view->execute_display('page', Array) views.module:466
views_page('admin_taxonomy_sizes', 'page') 
call_user_func_array('views_page', Array) menu.inc:516
menu_execute_active_handler() index.php:21

The reason is that my view is listing taxonomy terms in one vocabulary, with a relationship via a term reference field to terms in a second vocabulary. However, because the term reference field is not required, some rows have an empty value for the relationship term.

The problem is that the entity collector is not taking this possibility into account.

Comments

joachim’s picture

Title: entity collector produces warnings on views where not all rows produce an entity » entity collector produces 'Warning: array_flip' on views where not all rows produce an entity
Status: Active » Needs review
StatusFileSize
new838 bytes

Here's a patch.

Status: Needs review » Needs work

The last submitted patch, 1634692.relation.collector-views-skip-empty-rows.patch, failed testing.

joachim’s picture

Status: Needs work » Needs review
StatusFileSize
new862 bytes

*sigh*

marcus_clements’s picture

This patch does indeed get rid of the warning but some nodes in $view->result don't get loaded because they don't have a matching alias. I haven't worked out if this is good or bad.

chx’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Thanks for the patch but I really would like to see a test before this goes in.

joachim’s picture

I'm really not sure what a test would need to test or how to go about testing it.

Is that really necessary for such a small fix?

joachim’s picture

Here's a reroll in the meantime.

pingers’s picture

Status: Needs work » Needs review

Let's test the reroll - run into this too.

mikran’s picture

There is just 1 test case for entity collector so yes, a test to verify that collecting from a basic view would be nice step ahead in that regard.

There are tests for relation views but entity collector module is not enabled during those tests. I don't see any reason why this couldn't be the case. For this spesific issue any view that produces the error should be added, if one does not exist yet.

#1809166: Warnings on entity collector closed as duplicate to this.

jos_s’s picture

#7 works for me (version = "7.x-1.0-rc3").

mikran’s picture

StatusFileSize
new474 bytes
new1.3 KB

Here are the tests with entity collector enabled. At least locally I got some results (errors)

Status: Needs review » Needs work

The last submitted patch, tests_only-1634692-11.patch, failed testing.

kingswoodute’s picture

Subscribe. I get 18 of these errors in a view I am creating.

Thanks so much for the work you're doing. Relation is an amazingly good module!

mikran’s picture

Status: Needs work » Fixed

Committed 70700d3.

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