Media Handler - File Upload Component - problem saving fileReference

Description

Intro

There is a case that fileReference is set as an array in the JCR.

This happens when there is an image, which already has an asset set, editing it, clearing the reference and setting a new image.

Reproduction

Actual behavior

fileReference

String[]

/content/dam/myproject1/prague.jpg, /content/dam/myproject1/prague.jpg

Expected behavior

fileReference

String

/content/dam/myproject1/prague.jpg

Side note

Activity

Show:

Stefan Seifert February 24, 2020 at 4:33 PM

fixed in Media Handler 1.9.0 with this PR

Stefan Seifert February 24, 2020 at 3:54 PM

Benjamin Kalbitz February 19, 2020 at 11:28 AM

The problem lies in wcm-io/handler/media/components/granite/form/fileupload
where two components are merged together

  1. cq/gui/components/authoring/dialog/fileupload

  2. wcm-io/wcm/ui/granite/components/form/pathfield

  • Both Components holds an input field for './fielReference'

  • cq/gui/components/authoring/dialog/fileupload has a javascript function that deletes duplicated input fields _removeDuplicateHiddenInputs when the component is created

So the composition of both components works most of the time. But, when the component is saved without an image and opened again, cq/gui/components/authoring/dialog/fileupload holds the input field instead of wcm-io/wcm/ui/granite/components/form/pathfield.
This could be because wcm-io/wcm/ui/granite/components/form/pathfield has no './fielReference' input field at this time or the _removeDuplicateHiddenInputs function removes the field in another order.
When an image is then dropped in the component wcm-io/wcm/ui/granite/components/form/pathfield also gets a './fielReference' input field. So the value is posted twice.

Fixed

Details

Assignee

Reporter

Components

Priority

Created February 18, 2020 at 10:42 AM
Updated February 24, 2020 at 4:33 PM
Resolved February 24, 2020 at 4:33 PM