- π¦πΊAustralia mstrelan
I attempted to re-roll for 11.x and convert this to an MR but it proved difficult due to changes in π Create an UploadedFile validator and deprecate error checking methods on UploadedFileInterface RTBC . I wondered if this issue is still relevant but it is lacking steps to reproduce.
- π¬π§United Kingdom catch
I looked at the diff in https://git.drupalcode.org/project/drupal/-/commit/6bd3ad841f346d650ace3... and I also can't tell what's left here.
::handleFileUpload() creates violations, these are then formatted into a messenger message here: https://git.drupalcode.org/project/drupal/-/commit/6bd3ad841f346d650ace3...
The issue summary is saying that instead of listing the errors, we should log them. The errors we list now are validation constraints, not the raw message, so I think that's fine.
However, it looks like whereas we used to cover
UPLOAD_ERR_NO_TMP_DIR
as an explicit case in FileUploadHandler::handleFileUpload() https://git.drupalcode.org/project/drupal/-/commit/6bd3ad841f346d650ace3... that wasn't handled in the new code, and I can't see anywhere else in core that it's handled. Symfony's FileValidator does handle it explicitly but I don't think we're using that.Given all that, if the above is correct, which I'm not 100% sure it is, then I think what we're missing is logging the full range of errors we used to throw exceptions for, but now only show a handful of violation messages for.
- π¬π§United Kingdom catch
I just committed [#/2838474] which I'm not sure directly affects this issue but might influence the eventual outcome even if it doesn't.
- π¦πΊAustralia kim.pepper πββοΈπ¦πΊSydney, Australia
I believe it's because of how we move uploaded files.
We call
\Drupal\Core\File\FileSystem::moveUploadedFile()
which calls\move_uploaded_file()
. We don't call\Symfony\Component\HttpFoundation\File\UploadedFile::move()
which would throw those exceptions. From looking at the comments, due to a lack of stream wrapper support. - π¦πΊAustralia kim.pepper πββοΈπ¦πΊSydney, Australia
We could add those missing validations to
\Drupal\file\Validation\Constraint\UploadedFileConstraintValidator::validate()
, I'm just not sure if they are triggered before we try and move the file. - π¦πΊAustralia kim.pepper πββοΈπ¦πΊSydney, Australia
We are catching
UPLOAD_ERR_NO_TMP_DIR
in https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/file/...default => $this->context->buildViolation($constraint->uploadErrorMessage, [ '%file' => $value->getClientOriginalName(), ])->setCode((string) $value->getError()) ->addViolation()
This means this issue is about adding additional logging to
file_save_upload()
which would reclassify it as a task, IMO.