Bug 14973: Fix edit a suggestion and dup found
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 18 Nov 2019 15:53:41 +0000 (16:53 +0100)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Thu, 2 Jan 2020 12:36:26 +0000 (12:36 +0000)
The find duplicate call must only be done when the suggestion is new. It
does not make sense to search for a duplicate when the suggestion
already exists.

This patch also fixes a side-effect:
- Create a suggestion using an existing biblio title
- Ignore the warning and save
- Edit again and save
=> BOOM on date

Template process failed: undef error - The given date (18/11/2019) does
not match the date format (iso) at /kohadevbox/koha/Koha/DateUtils.pm
line 168

The dates are not processed and so badly formatted when sent to the
template.

Sponsored-by: BULAC - http://www.bulac.fr/
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

suggestion/suggestion.pl

index ba27992..6b655f8 100755 (executable)
@@ -132,7 +132,7 @@ if ( $op =~ /save/i ) {
             itemtype => $suggestion_only->{itemtype},
     });
 
-    if ( ( my ($duplicatebiblionumber, $duplicatetitle) = FindDuplicate($biblio) ) && !$save_confirmed ) {
+    if ( !$suggestion_only->{suggestionid} && ( my ($duplicatebiblionumber, $duplicatetitle) = FindDuplicate($biblio) ) && !$save_confirmed ) {
         push @messages, { type => 'error', code => 'biblio_exists', id => $duplicatebiblionumber, title => $duplicatetitle };
         $template->param(
             messages => \@messages,