Incorrect redirect hash generated

Created on 2 April 2019, over 5 years ago
Updated 24 January 2024, 11 months ago

When removing a file from an entity then uploading one with exactly the same name the following error is produced when trying to save the entity:

The website encountered an unexpected error. Please try again later.

Drupal\Core\Entity\EntityStorageException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'SomeHash' for key 'hash': INSERT INTO {redirect}...

Filefield Paths generates a hash for each redirect it creates and uses it to check if the redirect already exists. Currently Filefield Paths generates this hash using the target or destination path, while the Redirect module uses the source path with the leading slash removed.

This results in Filefield Paths never finding the existing redirect and trying to create a new one.

To resolve this, the module needs to generate a hash the same way as Redirect does. See Drupal\redirect\Entity\Redirect.

🐛 Bug report
Status

Needs work

Version

1.0

Component

Code

Created by

🇦🇺Australia imclean Tasmania

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

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