Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-27622

Ubpublished translation's preview throws error

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: High High
    • Resolution: Fixed
    • Affects Version/s: 1.9.1, 1.7.4
    • Fix Version/s: 1.10.0
    • Component/s: Content > PreView
    • Labels:
      None

      Description

      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:

      1. Create a content in the default german language, publish it.
      2. Create a translation in french, save it, don't publish it, click on the desktop preview icon in the right sidebar.
      3. 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":

      $this->translationHelper->getTranslatedField($content, $fieldDefIdentifier, $forcedLanguage)->value;

      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

        Activity

        Hide
        Kamil Madejski added a comment - - edited

        Confirmed also in 1.7.x.

        This issue was fixed in 1.10 release within PR: https://github.com/ezsystems/ezpublish-kernel/pull/2002. Improvement with prioritizedFieldLanguageCode property solves problem.

        Previously, https://github.com/ezsystems/ezpublish-kernel/blob/6.7/eZ/Publish/Core/Repository/Values/Content/Content.php#L76 used $this->versionInfo->contentInfo->mainLanguageCode (e.g. eng-GB), but $content passed to ez_render_field() contained fields in currently previewed language only, so Content::getField() returned null and Twig Exception was thrown.

        André Rømcke is it possible to add #2002 to the 6.7 or should I look for another way to fix it in 6.7?

        Show
        Kamil Madejski added a comment - - edited Confirmed also in 1.7.x. This issue was fixed in 1.10 release within PR: https://github.com/ezsystems/ezpublish-kernel/pull/2002 . Improvement with prioritizedFieldLanguageCode property solves problem. Previously, https://github.com/ezsystems/ezpublish-kernel/blob/6.7/eZ/Publish/Core/Repository/Values/Content/Content.php#L76 used $this->versionInfo->contentInfo->mainLanguageCode (e.g. eng-GB), but $content passed to ez_render_field() contained fields in currently previewed language only, so Content::getField() returned null and Twig Exception was thrown. André Rømcke is it possible to add #2002 to the 6.7 or should I look for another way to fix it in 6.7?

          People

          • Assignee:
            Unassigned
            Reporter:
            Gábor Balogh
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: