The Field Language API function field_language()
may return the wrong display language for an entity which is in the process of being created (e.g., during the preview of a node which references the entity).
The reason for this bug is the static variable cache $display_languages
in the function. It caches display languages by entity ID. However, newly created entities do not have any ID, yet, in which case a cache entry for NULL
is being created. If multiple different entities (especially of different bundles) are being created in one form, then this may lead to the same display language being returned for all those different entities.
I’ll suggest a patch in a minute which excepts display language caching for newly created entities.