If the form controllers sets the language to the default language and the language module is not enabled, $entity->language() won't work as the default language cannot be loaded via language_load() then. Everything is fine if the language module is enabled, however we do not want the entity system to depend on that. Right now - in order to work properly - it does. :/
To fix, we need to make sure that $entity->language() is set to a valid value and works. Presuming that language_default() should be valid, I think it should be loadable via language_load() as well then.
Comments
Comment #1
plachWhat's wrong with calling
language_default()
?Comment #2
fagoThe code there just has langcode and needs to get the language, so it uses language_load(). But that doesn't work for teh default language. Of course, we could special case that and check for the langcode being default language, but I do think this is something we probably want to fix in language_load() instead.
Comment #3
plachThis is being fixed in #1253820: It's impossible to submit no value for a field that has a default value.
Comment #4
plachRepurposing. Postponed on the issue above.
Comment #5
plachComment #6
plachThere is a bit more dicussion in #1966436: Default *content* entity languages are not set for entities created with the API.