Problem/Motivation
In #3401734: Refactor FileUploadResource to use FileUploadHandler we are trying to refactor out duplicate upload code by re-using FileUploadHandler. However, core file field uploads that currently use FileUploadHandler will rename to filename property of a File entity if
- There is a security rename
- There is an existing file with that name (using EXISTS_RENAME)
e.g. https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/file/...
// Update the filename with any changes as a result of security or renaming
// due to an existing file.
$file->setFilename($this->fileSystem->basename($file->getFileUri()));
However, FileUploadResource and TemporaryJsonapiFileFieldUploader only change the filename property of a File entity if
- There is a security rename
Steps to reproduce
Proposed resolution
Update FileUploadResource and TemporaryJsonapiFileFieldUploader to match the behaviour of the core file field upload. See#2.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Issue fork drupal-3402981
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:
- 3402981-filename-property-is
changes, plain diff MR !5486
Comments
Comment #2
larowlanI think it makes sense to make the behaviour consistent here.
This comment on the name field in the file entity indicates the URI and filename should be consistent
Comment #4
kim.pepperLooks like the change is minor. Needed to update the REST test expectations.
Comment #5
smustgrave commentedSeems simple enough
Comment #6
kim.pepperComment #7
kim.pepperComment #8
kim.pepperComment #9
quietone commentedI'm triaging RTBC issues. I read the IS and the comments. Thanks for the links in the IS, it made this easy to review.
The proposed resolution read as if confirmation was still needed. Since that is in #2 I updated the proposed resolution..
I left a question in the MR so I am setting back to NW for a reply.
Comment #10
kim.pepperComment #11
smustgrave commentedFeedback from @quietone appears to have been addressed.
Comment #13
larowlanCommitted to 11.x
Added and published a change record for the behaviour change
Comment #15
larowlan