I am receiving the following error on some views which contains a field collection which is empty.
Undefined offset: 0 in views_handler_field_field->set_items() (line 725 of /local/drupal-7.2/sites/all/modules/views/modules/field/views_handler_field_field.inc)
It does NOT appear on blocks. However, if the view is a list or a table, the warning appears for each data set that DOES NOT have the field collection data. So, If I have three users, and only one has data in the field "affiliations" (Title and Institution), then I receive two errors. If I fill in the fields for other users, the errors disappear. See also this issue:
http://drupal.org/node/1153066
Comments
Comment #1
OnkelTem commentedConfirmed.
I believe problem initiates in
field_collection_field_formatter_links()which doesn't check$itemsand when its empty still adds data to the$elementarray but with index -1:So we having
$elementsarray with the nice element:Later in
field.default.inc:232merging produces empty element:
Finally in
views/modules/field/views_handler_field_field.inc.views_handler_field_field->set_items(),$render_arrayis now containing this element which makeselement_children($render_array)to return key as there were a proper element to render, while there's not.Many words, but the patch is trivial. Attached.
Comment #2
OnkelTem commentedUpdated patch. Things go a bit tricky.
To get anything rendered in view fields, $render_array from
views/modules/field/views_handler_field_field.inc.views_handler_field_field->set_items()should has both #items and corresponding renderable children.
In case when we have Add link but have no items, it will never be rendered, since it dones't produce good child.
So we can add fake child.
See the patch.
Comment #3
OnkelTem commentedComment #5
OnkelTem commentedOops, old school patch failed.
Giving a try to new style, created with
diff -upr.Comment #6
chrisolofThe code changes from #5 fixed the issue for me. Attached is a patch with the same changes from #5, but created with "git diff."
Comment #7
vasikei can confirm this issue and the last solution #6 worked for me. thank you
Comment #8
jojonaloha commentedI've also experienced this issue and the patch in #6 solved this error message for me.
Comment #9
torotil commentedThe original patch doesn't apply anymore. Also I cannot reproduce the originally reported bug anymore. It seems that the patch had to wait too long in the issue queue and became stale.