Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-87914

Attribute fieldnamespace is not random enough for DDM-Fields

    Details

    • Fix Priority:
      1

      Description

      We have a huge Webcontent Structure with multiple repeatable fields.

      At one time, we created a webcontent based on this structure, published and then reloaded it. On reloading, a Javascript error appeared in the console:
      "TypeError: document.getElementById(...) is null"
      The article-form then became grayed-out and unresponsive.

      The Server-log greeted us with the following message:

      ERROR [http-nio-8080-exec-10][IncludeTag:128] Current URL /group/guest/~/control_panel/manage?p_p_id=com_liferay_journal_web_portlet_JournalPortlet&p_p_lifecycle=0&p_p_state=maximized&p_p_mode=view&_com_liferay_journal_web_portlet_JournalPortlet_mvcPath=%2Fedit_article.jsp&_com_liferay_journal_web_portlet_JournalPortlet_redirect=http%3A%2F%2Flocalhost%3A8080%2Fgroup%2Fguest%2F~%2Fcontrol_panel%2Fmanage%3Fp_p_id%3Dcom_liferay_journal_web_portlet_JournalPortlet%26p_p_lifecycle%3D0%26p_p_state%3Dmaximized%26p_p_mode%3Dview%26_com_liferay_journal_web_portlet_JournalPortlet_redirect%3Dhttp%253A%252F%252Flocalhost%253A8080%252Fgroup%252Fguest%252F%257E%252Fcontrol_panel%252Fmanage%253Fp_p_id%253Dcom_liferay_journal_web_portlet_JournalPortlet%2526p_p_lifecycle%253D0%2526p_p_state%253Dmaximized%2526p_p_mode%253Dview%2526_com_liferay_journal_web_portlet_JournalPortlet_displayStyle%253Dlist%2526_com_liferay_journal_web_portlet_JournalPortlet_showEditActions%253Dtrue%2526_com_liferay_journal_web_portlet_JournalPortlet_groupId%253D20143%2526_com_liferay_journal_web_portlet_JournalPortlet_folderId%253D429170%2526p_p_auth%253D82yg9rqQ%26_com_liferay_journal_web_portlet_JournalPortlet_displayStyle%3Dlist%26_com_liferay_journal_web_portlet_JournalPortlet_showEditActions%3Dtrue%26_com_liferay_journal_web_portlet_JournalPortlet_groupId%3D20143%26_com_liferay_journal_web_portlet_JournalPortlet_folderId%3D1207928%26p_p_auth%3D82yg9rqQ&_com_liferay_journal_web_portlet_JournalPortlet_referringPortletResource=&_com_liferay_journal_web_portlet_JournalPortlet_groupId=20143&_com_liferay_journal_web_portlet_JournalPortlet_folderId=1207928&_com_liferay_journal_web_portlet_JournalPortlet_articleId=6039860&_com_liferay_journal_web_portlet_JournalPortlet_version=1.0&p_p_auth=82yg9rqQ&js_fast_load=0 generates exception: com.liferay.portal.kernel.exception.PortalException: com.liferay.portal.kernel.template.TemplateException: Unable to process template com/liferay/dynamic/data/mapping/dependencies/alloy/option.ftl
      jodd.json.JsonException: Syntax error! Invalid char: <_offset: 0 near: "<p>["right..." [Sanitized]
      

       

      We then proceeded to check the articles content-xml and found out, that 2 fields share the same instanceId:

      <dynamic-element name="separatorVideoBlock" instance-id="teoe" type="selection_break" index-type="keyword">
          <dynamic-element name="videoContent" instance-id="rpku" type="text_area" index-type="keyword">
              <dynamic-content language-id="en_US"><![CDATA[["right"]]]></dynamic-content>
              <dynamic-content language-id="de_DE"><![CDATA[<p>["right"]</p>]]></dynamic-content>
          </dynamic-element>
          <dynamic-element name="videoType" instance-id="ncli" type="radio" index-type="keyword">
              <dynamic-content language-id="en_US"><![CDATA[["youtube"]]]></dynamic-content>
              <dynamic-content language-id="de_DE"><![CDATA[["youtube"]]]></dynamic-content>
          </dynamic-element>
          <dynamic-element name="videoSelection" instance-id="wnhz" type="document_library" index-type="keyword">
              <dynamic-content language-id="en_US"><![CDATA[]]></dynamic-content>
              <dynamic-content language-id="de_DE"><![CDATA[]]></dynamic-content>
          </dynamic-element>
          <dynamic-element name="videoId" instance-id="fbwc" type="text" index-type="keyword">
              <dynamic-content language-id="en_US"><![CDATA[kslaeOUk7N4]]></dynamic-content>
              <dynamic-content language-id="de_DE"><![CDATA[kslaeOUk7N4]]></dynamic-content>
          </dynamic-element>
          <dynamic-element name="thumbnail" instance-id="tpkl" type="document_library" index-type="keyword">
              <dynamic-content language-id="en_US"><![CDATA[/documents/20143/429323/index.svg/ec14f1ff-bf1b-11bc-0440-fc7d05c73195?t=1527664759283]]></dynamic-content>
              <dynamic-content language-id="de_DE"><![CDATA[/documents/20143/429323/index.svg/ec14f1ff-bf1b-11bc-0440-fc7d05c73195?t=1527664759283]]></dynamic-content>
          </dynamic-element>
          <dynamic-element name="caption" instance-id="mxse" type="text" index-type="keyword">
              <dynamic-content language-id="en_US"><![CDATA[Ascension - Miracle of Sound (Divinity: Original Sin 2)]]></dynamic-content>
              <dynamic-content language-id="de_DE"><![CDATA[Ascension - Miracle of Sound (Divinity: Original Sin 2)]]></dynamic-content>
          </dynamic-element>
          <dynamic-element name="VideoAltText" instance-id="zfob" type="text" index-type="keyword">
              <dynamic-content language-id="en_US"><![CDATA[Ascension - Miracle of Sound (Divinity: Original Sin 2)]]></dynamic-content>
              <dynamic-content language-id="de_DE"><![CDATA[Ascension - Miracle of Sound (Divinity: Original Sin 2)]]></dynamic-content>
          </dynamic-element>
          <dynamic-element name="alignment" instance-id="rpku" type="radio" index-type="keyword">
              <dynamic-content language-id="en_US"><![CDATA[["right"]]]></dynamic-content>
              <dynamic-content language-id="de_DE"><![CDATA[<p>["right"]</p>]]></dynamic-content>
          </dynamic-element>
      </dynamic-element>

      This is an extract from the content-xml. Note, that 2 fields share the instance-id "rpku". One of these fields is of type "radio" with 2 options. As you can see, one of these options is in a format which is not JSON-parsable and when beeing processed by "options.ftl", will result in the Exception above.

      I guess the article-form-render logic gets confused when ddm-fields share the same instanceId and mixes up their content.

      In its current state, the instanceId is only a 4-lowercased-characters-long alphabetical String (see com.liferay.portal.kernel.util.StringUtil.randomId()). This is not long enough to ensure that the id will be unique. I propose either increasing the length of the instanceId or implementing a mechanism to ensure, that all instanceIds are unique.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Days since last comment:
                51 weeks, 1 day ago

                Packages

                Version Package