From 3bb178100992935e71d8b32aade54d13ccd06823 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 29 Sep 2014 15:36:22 +0200 Subject: [PATCH] Bug 13005: suggestions.budgetid should be NULL if not filled On creating/updating a suggestion, the budgetid should be NULL or contain a budgetid, but not '0'. Test plan: 0/ Verify you have a suggestions.budgetid set to 0. 1/ Execute the updatedb entry and verify there is no budgetid==0 anymore. 2/ Create and update a suggestion selecting a fund and verify the budgetid DB field is correctly filled. 3/ Create and update a suggestion without selecting a fund and verify the budgetid DB field is set to NULL. --- C4/Suggestions.pm | 3 +++ installer/data/mysql/updatedatabase.pl | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm index eae80a0..494da50 100644 --- a/C4/Suggestions.pm +++ b/C4/Suggestions.pm @@ -427,6 +427,7 @@ sub NewSuggestion { my ($suggestion) = @_; $suggestion->{STATUS} = "ASKED" unless $suggestion->{STATUS}; + $suggestion->{budgetid} ||= undef; my $rs = Koha::Database->new->schema->resultset('Suggestion'); return $rs->create($suggestion)->id; @@ -449,6 +450,8 @@ sub ModSuggestion { my ($suggestion) = @_; return unless( $suggestion and defined($suggestion->{suggestionid}) ); + $suggestion->{budgetid} ||= undef; + my $rs = Koha::Database->new->schema->resultset('Suggestion')->find($suggestion->{suggestionid}); my $status_update_table = 1; eval { diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 6ea5911..5d2c50e 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -8781,6 +8781,15 @@ if ( CheckVersion($DBversion) ) { SetVersion($DBversion); } +$DBversion = '3.17.00.XXX'; +if ( CheckVersion($DBversion) ) { + $dbh->do(q{ + UPDATE suggestions SET budgetid=NULL WHERE budgetid=0 + }); + print "Upgrade to $DBversion done (Bug 13005: suggestions.budgetid should be NULL if not filled)\n"; + SetVersion($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) -- 2.1.0