Symptom
When attempting to create a new node with the OG prepopulated, I get the following PHP Warning:
Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 173 of /Volumes/Macintosh_HD/Users/samueloltz/Sites/rapid/crcna/includes/entity.inc).
Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->cacheGet() (line 350 of /Volumes/Macintosh_HD/Users/samueloltz/Sites/rapid/crcna/includes/entity.inc).
Cause
At first I thought it was an error with Entityreference prepopulate, but I traced the issue back to how og_context_handler_url() uses entityreference_prepopulate_get_values_from_url() on line 412. The function uses these values and puts them right into entity_load() on line 421. The problem is that entity_load() expects a single dimensional numeric array of entity ids to load, but the value return from entityreference_prepopulate_get_values_from_url() is a multi-dimensional, string keyed array.
Solution
The solution is to modify $ids, which is the value returned from entityreference_prepopulate_get_values_from_url(), before sending it to entity_load().
Comment | File | Size | Author |
---|---|---|---|
#1 | og_context.module-2118719-2.patch | 619 bytes | pianomansam |
Comments
Comment #1
pianomansam CreditAttribution: pianomansam commentedQuick attempt at a patch. Applied an array_map to prepare the $ids value for entity_load(). This will only work on PHP 5.3, however since it uses a lambda function.
Comment #2
shushu CreditAttribution: shushu commentedComment #3
shushu CreditAttribution: shushu commentedFirst, I wasn't able to reproduce the error.
Second, entityreference_prepopulate_get_values_from_url() return an array of values taken from the URL:
So I can't see a situation in which array_flip will get into troubles.
Still, in case you do encounter this problem, please send more info and I will try to reproduce it.
Comment #4
shushu CreditAttribution: shushu commentedComment #5
fagoran into this as well, ust be sure to have entityreference_prepopulate upgraded to a latest release.