Modules used: search-api-solr 7.x-1.0-rc2, entity-7.x-1.0-rc3, search-api-7.x-1.1
Repeatable: Always
When values is set to unlimited on the body of a content type, and "The main body text » Text" is selected for indexing, the following error is thrown and the body field is missing in the index:
Notice: Undefined index: value in entity_metadata_field_text_get() in entity/modules/callbacks.inc
Temporarily setting the content type to only allow one value, allows the node to be indexed correctly (for delta 0), the error is not thrown.
Expected behavior: Iterate through all body values when indexing. Though, only indexing delta 0 and ignoring the rest would already be a significant improvement in comparison to the missing body.
#1426144: When selecting fields to index add option to choose the delta for multivalued fields is related to this, but requests a specific delta rather than all.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | check-cardinality-body-property-1621002-5.patch | 562 bytes | valderama |
| #4 | entity-arrayworkaround-1621002-4.patch | 644 bytes | grahl |
| #2 | entity-arrayworkaround-1621002-2.patch | 757 bytes | grahl |
Comments
Comment #1
drunken monkeyThanks for reporting!
Seems like an Entity API bug. It seems they don't respect the cardinality of text fields when specifying the type of properties. At least that's what it looks like to me.
In any case, I can reproduce this.
Moving the issue …
Comment #2
grahlAttached is a patch which fixes the problem. It occurs due to the fact that with cardinality > 1 on the generic body field the contents of the $item array is wrapped within another array. So $item['value'] is actually $item[0]['value'].
Since the structure within the nested array is already as expected, ideally the input passed entity_metadata_field_text_get() would get fixed, rather than needing this workaround.
Comment #3
Marcus 78 commentedSame error but patch doesnt help at all
Comment #4
grahlPatch update avoids an E_NOTICE, not sure if the patch has a fundamental flaw or why it doesn't work for #3.
Comment #4.0
grahlFixed the link to other issue
Comment #5
valderama commentedThis bug is still valid in current dev of entity. It makes indexing body fields with search_api impossible if the cardinality is not 1.
I have attached a patch, which changes the property type to a list, if cardinality is not 1.
Please review.
Comment #6
mfbLooks good and patch is working as far as I can tell; haven't seen any regressions yet.
Comment #7
fagoGood fix, I agree it should be fine as it the setting is shared across all field instances. The comment has a typo though - I fix that on commit.
Comment #10
fago