Does not work on media types with multiple (different) file upload fields

Created on 16 December 2021, about 3 years ago
Updated 13 April 2023, over 1 year ago

Problem/Motivation

I have a media type with a PDF (source) and a doc/docx file field. The replace/overwrite original file only applies to the PDF, or source generally. I believe this is intended but I propose adding the the ability to overwrite any file fields associated to document. It is similar to 3131468 - Only works with single file β†’ except that does not seem to address if there is multiple/different file fields associated to one media type.

Steps to reproduce

Create a media with 2 file upload fields (one for PDF and one for docx for example) and try to overwrite the non media source file field.

Proposed resolution

I'm attaching a rough patch, that got this working for me currently but it will need work.

Remaining tasks

Assess/test initial patch and improve where necessary

✨ Feature request
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States billdaff

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Thanks for the patch including important tests!

    I guess we should first focus on πŸ› Implement support for content translation Fixed as that's a major issue. Once that's fixed, this one should be rerolled and fixed, too.

  • πŸ‡ΊπŸ‡ΈUnited States jsutta United States

    Did some testing on this and the first patch worked for me in Drupal 10 with version 8.x-1.1 of the module installed. #5 seemed to have no effect on the module's behavior.

  • πŸ‡ΊπŸ‡ΈUnited States jsutta United States

    Rerolled the patch against the latest version of the 8.x-1.x branch.

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.1.4 + Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    2 pass, 2 fail
  • πŸ‡ΊπŸ‡ΈUnited States jsutta United States

    Rerolled the patch after the latest release.

  • Status changed to Needs work about 1 year ago
  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Now that πŸ› Implement support for content translation Fixed is fixed, we should proceed here. Did others already try the patches here?
    #9 tests still fail.

    Any maintainer feedback?

  • πŸ‡ΊπŸ‡ΈUnited States kurttrowbridge

    I've been looking into this one because I'm having issues with a use case very similar to what's described in the original issue: a Media entity with two single-value File fields, one allowing PDFs and one allowing DOC/DOCX files.

    Not sure if I'm just confused, but #9 doesn't seem to be addressing the use case of a Media entity with multiple File fields (not necessarily one or more multivalue fields), and seems more like it's addressing multivalue fields. #1 did seem to do so, so unless I'm missing anything on #9, my next attempt will be to fix the patch in #1 to work with the latest version of the module.

  • @kurttrowbridge opened merge request.
  • πŸ‡ΊπŸ‡ΈUnited States kurttrowbridge

    I did go back and work from the original patch to create a new one, and I think I now have a working solution that's ready for review; see the provided merge request. This should address the use case of a Media entity that contains multiple File fields (mine are a PDF and a DOCX, just like the case described in the original issue; both of mine are also single-value fields).

    I'll attach a screenshot of my entity edit form as well, in which there's a "Replace file: ___" field for each file field, correctly identifying the field name and its allowed extensions.

    I did a fair bit of testing with updating one or both files, with and without overwriting the file name, along with the creation of new Media entities, and didn't run into any issues. I would definitely appreciate additional reviews, though, especially given that I leaned on AI more than I typically do. Hopefully this will help for others as well.

    Thanks!

Production build 0.71.5 2024