found core bug :File cannot be replaced message gives incorrect filename

Created on 7 February 2020, over 5 years ago
Updated 25 June 2025, 9 days ago

on line 1077 of the file .module it has this
\Drupal::messenger()->addError(t('The file %source could not be uploaded because a file by that name already exists in the destination %directory.', ['%source' => $form_field_name, '%directory' => $destination]));

it should be this :
\Drupal::messenger()->addError(t('The file %source could not be uploaded because a file by that name already exists in the destination %directory.', ['%source' => $file->getFilename(), '%directory' => $destination]));

if not it does not identify the name of the file correctly

🐛 Bug report
Status

Closed: outdated

Version

11.0 🔥

Component

file system

Created by

🇺🇸United States dianacastillo Miami

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.

  • 🇮🇳India mohit_aghera Rajkot

    This issue doesn't exist anymore.
    File upload handler has updated the message and the current updated message contains actual filename.

    https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/file/...

       $filename = $event->getFilename();
    
        $mimeType = $this->mimeTypeGuesser->guessMimeType($filename);
        $destinationFilename = $this->fileSystem->getDestinationFilename($destination . $filename, $fileExists);
        if ($destinationFilename === FALSE) {
          throw new FileExistsException(sprintf('Destination file "%s" exists', $destinationFilename));
        }
    

    I think we should close this.
    Please reopen if you feel it is still valid.

Production build 0.71.5 2024