Containers: Cannot print properly image/file fields of contents added to container
If a content type has 2 or more image/file fields, there is a problem with how contents are printed once they're added to a container.
Expected Behavior
Values of fields should always be displayed on frontend pages, according to the container's code.
Current Behavior
There is an apparent 'leak' of image/file fields when there are multiple contents added to a container and the parent content types have 2 or more Image/File fields. If the first content on top of the container have valid values on these fields, it doesn't matter if all remaining contents have these fields populated or not. 1+N Image/file fields will repeat the same value from the first content.
Possible Solution
Check how contents are validated and add support on Java logic for multiple image/file fields if missing.
Known Workarounds
none.
Steps to Reproduce (for bugs)
- Create a test container for Event contents. Set Max contentlets value to 5 and use this as container's code
$!{title}
<br>
<br>
<br>
sp1 $!{image}
$!{imageImageIdentifier}
<br>
#if ($UtilMethods.isSet(${imageImageURI}))
<img src="$!{imageImageURI}" alt="$!{imageImageTitle}" />
#end
<br>
sp2 $!{file}
$!{fileFileIdentifier}
<br>
#if ($UtilMethods.isSet(${fileFileURI}))
<img src="$!{fileFileURI}" alt="$!{fileFileTitle}" />
#end
-
Create a template and parse the newly created container.
-
Create a page with the newly created container.
-
Add 3 Event containers.
-
Test Event 001 havs its Image/File fields populated.

-
Test Event 002 has only one Image/File field populated:

-
- Test Event 003 has only one Image/File field populated

- If you look at the page, you'll see that the File Image is repeated across all other contents, despite these ones are NOT part of the actual content being printed on the Velocity Context.
-
Test Event 001 - Live Mode. It shows its two Image/File fields as expected.

-
Test Event 002 - Live mode. It shows its first Image/File field, but it prints the File one from 1st content

e255d31b3b60.png">
- Test Event 003 - Live mode. It shows its first Image/File field, but it prints the File one from 1st content as well

Context
Reported by customer: https://my.dotcms.com/tickets/detail.dot?id=decad80d-95f9-4d59-9671-2e3b82f7475b.
Your Environment
- dotCMS 4.x
- Any OS/Browser.
- Tomcat 8.0.18.
- Java 8u121.
- Postgres DB.
PR for master repo: https://github.com/dotCMS/core/pull/11655
PRs for removing validation: https://github.com/dotCMS/core/pull/12011, https://github.com/dotCMS/core/pull/12014
Passed QA Followed steps to reproduce. I was able to see the contents being printed properly on each test event ( Test Event 001, Test Event 002 and Test Event 003)
Tested locally using the following environments: Upgrade from dotcms_3.6 with client dataset (db and assets) to master branch / commit 166c46f5c177b8b155fb7b2ceb9072f25f68432d MacOSx 10.10 / Postgres 9.3.7 / Chrome v54.0.2840.98 / Tomcat 8 / Java 8