From 01eb55e60e7e37151ccfd8ac08e882c1630fe63d Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 16 Feb 2017 16:02:48 -0300 Subject: [PATCH] Bug 13757: Attribute with value 0 should be stored Signed-off-by: Tomas Cohen Arazi --- Koha/Patron/Modification.pm | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Koha/Patron/Modification.pm b/Koha/Patron/Modification.pm index 718ffe4682..78f092d2fe 100644 --- a/Koha/Patron/Modification.pm +++ b/Koha/Patron/Modification.pm @@ -54,8 +54,7 @@ sub store { )->count() ) { - Koha::Exceptions::Patron::Modification::DuplicateVerificationToken - ->throw( + Koha::Exceptions::Patron::Modification::DuplicateVerificationToken->throw( "Duplicate verification token " . $self->verification_token ); } } @@ -74,7 +73,6 @@ sub store { return $self->SUPER::store(); } - =head2 approve $m->approve(); @@ -106,8 +104,7 @@ sub approve { # Take care of extended attributes if ( $self->extended_attributes ) { - $extended_attributes - = try { decode_json( $self->extended_attributes ) } + $extended_attributes = try { decode_json( $self->extended_attributes ) } catch { Koha::Exceptions::Patron::Modification::InvalidData->throw( 'The passed extended_attributes is not valid JSON'); @@ -136,13 +133,17 @@ sub approve { attribute => $attr->{value} } )->store - if $attr->{value}; + if $attr->{value} # there's a value + or + ( defined $attr->{value} # there's a value that is 0, and not + && $attr->{value} ne "" # the empty string which means delete + && $attr->{value} == 0 + ); } } catch { if ( $_->isa('DBIx::Class::Exception') ) { - Koha::Exceptions::Patron::Modification->throw( - $_->{msg} ); + Koha::Exceptions::Patron::Modification->throw( $_->{msg} ); } else { Koha::Exceptions::Patron::Modification->throw($@); @@ -154,7 +155,6 @@ sub approve { return $self->delete(); } - =head3 type =cut -- 2.11.1