Problem/Motivation
I have a DAM metadata field mapped to the media name:
field_map:
documentName: name
I'm using the acquiadam_asset_import submodule to import assets.
When a media is created by the import, the media name is always the file name from the DAM. That's because of this code: https://git.drupalcode.org/project/acquia_dam/-/blob/1.1.x/modules/acqui...
If I re-sync the metadata manually, the name gets corrected.
Steps to reproduce
Proposed resolution
Honor the field mapping during media creation via acquiadam_asset_import.
That would probably happen in AssetQueueService::filterAndFormatAsset()
https://git.drupalcode.org/project/acquia_dam/-/blob/1.1.x/modules/acqui...
Or maybe we don't even set the name? I think that would work for us since acquia_dam_media_presave would set the name. But what if the name isn't explicitly mapped? Is there some magic to set a default name?
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork acquia_dam-3580543
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
danflanagan8A response to
Maybe the
Assetsource plugin would need to be updated too? Such that the'default_name'case ofAsset::getMetadataconsiders the field_mapping configuration instead of using$asset['filename'];?https://git.drupalcode.org/project/acquia_dam/-/blob/1.1.x/src/Plugin/me...
Comment #5
rajeshreeputraRequesting review.
Comment #6
danflanagan8That fix looks reasonable. I applied the MR as a patch and confirmed that a newly imported asset has the expected name now. so that's good.
That said, I got a WSOD on the cron page:
What was null? That code that creates the failing log looks like this:
After some debugging, I see that
$data['file_name']is the value that is somehow NULL. I also see a warning:This is interesting because the patch "works" but it works for the wrong reason. It seems like the patch accidentally does what I suggested in comment #2. If we simply don't set the
namein the queue worker, the correct default value gets applied.I'm not exactly sure what the best thing to do is, but this is definitely NW.
Comment #7
danflanagan8I dug a bit deeper and it looks like the
$asset_dataarray infilterAndFormatAssetdoesn't have any of the custom asset metadata.Given that, I definitely suggest a less-is-more approach here. We simply shouldn't set the
namewhen creating the media in the queue worker. We should just let all the other infrastructure in acquia_dam and core media deal with getting the name right.Comment #9
danflanagan8I opened up a separate MR with my proposed fix. It's the less-is-more approach.
I tested this locally with good results. When I have a mapping for
name, my imported media get the correct name. If I do not have a mapping forname, the file name ends up getting used.Comment #10
rajeshreeputraThats reasonable. Rebased MR!279.
Comment #13
rajeshreeputraMR merged!