@@ -, +, @@ --- admin/branches.pl | 20 ++++++++--- .../data/mysql/atomicupdate/bug_28567.perl | 34 +++++++++++++++++++ 2 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_28567.perl --- a/admin/branches.pl +++ a/admin/branches.pl @@ -90,7 +90,12 @@ if ( $op eq 'add_form' ) { if ($is_a_modif) { my $library = Koha::Libraries->find($branchcode); for my $field (@fields) { - $library->$field( scalar $input->param($field) ); + if ( $field eq 'pickup_location' ) { + # Don't fallback to undef/NULL, default is 1 in DB + $library->$field( scalar $input->param($field) ); + } else { + $library->$field( scalar $input->param($field) || undef ); + } } try { @@ -118,12 +123,19 @@ if ( $op eq 'add_form' ) { } catch { push @messages, { type => 'alert', code => 'error_on_update' }; - } + }; } else { $branchcode =~ s|\s||g; my $library = Koha::Library->new( - { branchcode => $branchcode, - ( map { $_ => scalar $input->param($_) || undef } @fields ) + { + branchcode => $branchcode, + ( + map { + $_ eq 'pickup_location' # Don't fallback to undef/NULL, default is 1 in DB + ? ( $_ => scalar $input->param($_) ) + : ( $_ => scalar $input->param($_) || undef ) + } @fields + ) } ); --- a/installer/data/mysql/atomicupdate/bug_28567.perl +++ a/installer/data/mysql/atomicupdate/bug_28567.perl @@ -0,0 +1,34 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + + my @fields = qw( + branchname + branchaddress1 + branchaddress2 + branchaddress3 + branchzip + branchcity + branchstate + branchcountry + branchphone + branchfax + branchemail + branchillemail + branchreplyto + branchreturnpath + branchurl + branchip + branchnotes + opac_info + marcorgcode + ); + for my $f ( @fields ) { + $dbh->do(qq{ + UPDATE branches + SET $f = NULL + WHERE $f = "" + }); + } + + NewVersion( $DBversion, 28567, "Set to NULL empty branches fields"); +} --