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

Issue fork drupal-3112004

Command icon 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:

Comments

dianacastillo created an issue. See original summary.

dianacastillo’s picture

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

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

lendude’s picture

Version: 8.9.x-dev » 9.3.x-dev
Status: Active » Needs review
Issue tags: +Bug Smash Initiative
StatusFileSize
new10.19 KB
new11.3 KB

Might be more of a task than a bug, but let's treat it like a bug.

Changed the message as suggested in the IS and added test coverage for the error, which was missing. Also updated the comment so it no longer points to a constant that no longer exists.
Adding a test-only patch, but its a bit iffy since I wouldn't expect that to pass since we are changing the output.

Before the error would read something like :
The file <em class="placeholder">file_test_upload</em> could not be uploaded because a file by that name already exists in the destination <em class="placeholder">temporary://</em>.

After it will show:
The file <em class="placeholder">image-test.png</em> could not be uploaded because a file by that name already exists in the destination <em class="placeholder">temporary://</em>.

lendude’s picture

StatusFileSize
new1.9 KB

Now without the unrelated test getting added......

kim.pepper’s picture

This may or may not get in before #3232248: Move _file_save_upload_single to a service and deprecate which is a major rework. Linking it here.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

joachim’s picture

Status: Needs review » Reviewed & tested by the community

Patch looks good to me.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 5: 3112004-5.patch, failed testing. View results

kim.pepper’s picture

Status: Needs work » Needs review
StatusFileSize
new1.97 KB

Re-roll of #5 for 10.0.x

Status: Needs review » Needs work

The last submitted patch, 10: 3112004-10.patch, failed testing. View results

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

mohit_aghera’s picture

Status: Needs work » Closed (outdated)

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.