We have a multi-language site, that has german, french and italian languages. The default language is german, siteaccesses are based on the domain (each language has different domains), the admin is usually used whith the german domain, there is no extra siteaccess for the admin.
Step to reproduce:
- Create a content in the default german language, publish it.
- Create a translation in french, save it, don't publish it, click on the desktop preview icon in the right sidebar.
- There is a Symfony exception in the preview area: "Trying to get property of non-object"
It originates from the twig template of the content where there is an ez_field_value(content, "field_name") call. The call gets to Twig's ContentExtension, where getTranslatedFieldValue() tries to get the 'value' property of that "non-object":
I dumped some values and the problem seems to be:
- ez_field_value() doesn't pass a forcedLanguage
- ContentExtenstion's getTranslatedFieldValue() calls TranslationHelper's getTranslatedField() where the getLanguages() returns the german language only (as default language)
- The content object has only the french values loaded, so non of the getField() calls in getTranslatedField() returns Field object, therefore the getTranslatedField() returns nothing
- ContentExtenstion getTranslatedFieldValue() gets that "nothing" and tries to get the value property of it, this is where the error occurs