Managed-file uploads do not support multiple actions per submit, and can't be replaced without multiple submits.

Created on 17 December 2020, over 4 years ago
Updated 1 April 2025, 1 day ago

Problem/Motivation

I'm using the upload feature in an edit form.
I can successfully upload or delete an image file, but a replacement,
removing an existing file followed by an Upload with the same submit
results in the persistence of the "removed" file plus the new file
with a status code of zero (0).
Displaying the replaced file after a short time causes a wsod,
since CRON removes temporary files.

Steps to reproduce

This can be reproduced by downloading the hello and common
modules here.
Applicable code is also posted in the files section.
Screen shotsin the files illustrate the issue. They are prefixed with the same step Ids (1a - 5a)
as their explanations below:

1a. Controller image with original file (Louvre 124).
1b. Original file_managed view.
2a Edit image before Removal.
2b. file_managed view before removal (same as 1b).
3a. Edit image after Removal but before Addition.
3b. file_managed view after removal but before addition (same as 1b).
3c. File directory view before submit. Only the original file (Louvre 124) is shown.
4a. Edit image after addition of new file (Louvre 132) but before the Submit action.
4b. File directory view after submit. Both files are stored.
4c. file_managed view after submit. showing new file with status=0 and the original file (louvre124).
5a. Controller image after the Submit of the Edit image showing only the new file (Louvre132).

Proposed resolution

I'm not familiar with the Drupal image system and can't be sure of the cause or offer a resolution.
Therefore I'm initially submitting it as a support request. If anyone finds a correction or a workaround, I'll use that. If the managed file works as designed, I'll change the status to a new feature request. If it's an error, I'll change the status to a bug report. Any comments are appreciated.

Remaining tasks

I'm not familiar with the Drupal image system

User interface changes

I added a workaround to change the status to permanent in the Controller module
of another module (asset), but the old, replaced file remains.
I also added a warning message.

API changes

Not applicable.

Data model changes

Not applicable.

Release notes snippet

None.

πŸ› Bug report
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

file system

Created by

πŸ‡ΊπŸ‡ΈUnited States othdvlpr

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.

Production build 0.71.5 2024