If you're using path redirect for files, this might also be an important issue for you to follow.
#1238418: percent-encoded characters in URLs are double-encoded
When a node is deleted, any redirects which pertain to this file are not deleted.
Now I understand this is a little out of scope for this project perhaps, my main problem with it, that if I try to save the redirect again when re-importing this file, I get a fatal error.
There are three ways we could resolve this would be:
1. When a file is deleted, also delete any redirects where that file is the destination.
2. Make the addition of duplicate $redirect['source'] a warning instead of fatal. And do nothing else.
3. When a new entry is saved, that has the same source, overwrite the previous entry.
Personally I'm a fan of #3. The reason for this being, that is someone decides to save a new entry for a source, where the source already exists, that's probably the desired behavour they want, for it to get replaced. A Fatal error, is probably not what the want to see.
Here's the fatal error I receive when I do a duplicate redirect:
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'GICTvW-Uzt8_U6kEkLKbFtv4iZZ64UNQL4ZhTHIERwc' for key 2: INSERT INTO {redirect} (hash, type, uid, source, source_options, redirect, redirect_options, language, status_code, count, access) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10); Array ( [:db_insert_placeholder_0] => GICTvW-Uzt8_U6kEkLKbFtv4iZZ64UNQL4ZhTHIERwc [:db_insert_placeholder_1] => redirect [:db_insert_placeholder_2] => 1 [:db_insert_placeholder_3] => PathToFile.mp3 [:db_insert_placeholder_4] => a:0:{} [:db_insert_placeholder_5] => sites/default/files/podcasts/James Turk 2:5:2012_0.mp3 [:db_insert_placeholder_6] => a:0:{} [:db_insert_placeholder_7] => und [:db_insert_placeholder_8] => 0 [:db_insert_placeholder_9] => 0 [:db_insert_placeholder_10] => 0 ) in drupal_write_record() (line 6975 of htdocs/includes/common.inc).
As my old Java instructor used to say, you could only throw exceptions for Exceptional cases....not use them for ones you can catch ahead of time.
Here's an issue on better handling of duplicates as well:
#1250710: Validation does not working
Comments
Comment #0.0
j0rd commentedadded duplicate save handler.
Comment #1
wylbur commentedMarking this as resolved in #1250710.