Problem/Motivation
Both EntityReference_SelectionHandler_Translation_Generic_node and EntityReference_SelectionHandler_Translation_Generic_taxonomy_term are wrong. With it's current code they only work on Entity Reference (ER) in one case:
Node context:
ER field that points to nodes: OK
ER field that ponts to taxonomies: KO *
Taxonomy context:
ER field that points to nodes: KO
ER field that ponts to taxonomies: KO
The problem is that in EntityReference_SelectionHandler_Translation_Generic_node the function i18n_node_i18n_context_language is called to obtain the language of the node in context but the ER field could be in a taxonomy context too!
The same problem happens in EntityReference_SelectionHandler_Translation_Generic_taxonomy_term: the function i18n_taxonomy_i18n_context_language is called to obtain the language of the taxonomy in context but the ER field could be in a node context too!
* This notice shows up:
Notice: Undefined index: locale in EntityReference_SelectionHandler_Translation_Generic_taxonomy_term->entityFieldQueryAlter() (line 95 of /sites/all/modules/contrib/translated_entityreference/plugins/selection/EntityReference_SelectionHandler_Translation_Generic.class.php).
It is highly recommended to also apply patch of issue 2762971.
Proposed resolution
Call both i18n_node_i18n_context_language and i18n_taxonomy_i18n_context_language in both handlers and then use the result of two which is not empty.
Fix EntityReference_SelectionHandler_Translation_Generic_taxonomy_term (it lacks getReferencableEntities implementation).
Remaining tasks
None. Test this by editing nodes and taxonomies with ER fields.
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | interdiff.txt | 3.66 KB | rcodina |
| #15 | module_s_entity-2764093-15.patch | 6.86 KB | rcodina |
| #14 | interdiff.txt | 615 bytes | rcodina |
| #14 | module_s_entity-2764093-14.patch | 4.41 KB | rcodina |
Comments
Comment #2
rcodinaComment #3
rcodinaComment #4
rcodinaComment #5
rcodinaComment #6
rcodinaComment #7
rcodinaComment #8
rcodinaComment #9
rcodinaComment #10
rcodinaComment #11
rcodinaComment #12
rcodinaComment #13
rcodinaCustom implementation of getReferencableEntities didn't follow configuration of field.
Comment #14
rcodinaSolved bug on creation.
Comment #15
rcodinaOptional: I improved patch on 14 so now the entity labels appear with a suffix containing its translation in website default language. The translation is added between parenthesis. This may be useful when you admin a website in languages you don't know. However, I recommend patch 15.
Comment #16
rcodinaComment #17
AsadKamil commentedHi All,
This patch 15 works fine for 7x branch. Thanks.
Comment #18
rcodina@AsadKamil Download latest dev version and use module_s_entity-2764093-15.patch, edit_when_user_changes-2762971-19.patch and module_not_working-2267853-7.patch patches. Remember to enable the submodule!