Bug 35929: Don't record a change for empty fields submitted in patron form
This is reminiscent of bug 36159 - when a field is submitted as empty, and null in the DB we need to reject this as a change. I tried to copy the logic from that bug, as well as deleting submitted changes for hidden fields (from html manipulation) This should be tested extensively. One note: If you submit a valid change request, then submit a second with no change the second will be ignored, but the first will remain. i.e. if you change your name from 'Nick' to 'Nack' - then realize your typo you cannot submit a new request to change it back untl the initial request is cleared To test: 1 - Play with PatronSelfModificationBorrowerUnwantedField and PatronSelfModificationMandatory field to have some fields set 2 - Add a patron attribute, or several, that are editable in the OPAC 3 - Try submitting a form with no changes, note a modification requets is submitted 4 - Approve the request 5 - Apply patch, restart all 6 - Try submitted a blank request, you are notified there were no changes 7 - Try to force an unwanted field via html modification 8 - No changes reported 9 - Confirm attributes changes are successful 10 - After a successful request, try submitting a blank request 11 - Note no changes are recorded, but the initial request is still active Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de> (cherry picked from commitcf4a3667cb) Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com> (cherry picked from commit1a898d9464) Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
ce48510c21
commit
2e8a9bd95d
|
|
@ -336,7 +336,7 @@ elsif ( $action eq 'update' ) {
|
|||
$borrower_changes{'changed_fields'} = join ',', keys %borrower_changes;
|
||||
my $extended_attributes_changes = FilterUnchangedAttributes( $borrowernumber, $attributes );
|
||||
|
||||
if ( %borrower_changes || scalar @{$extended_attributes_changes} > 0 ) {
|
||||
if ( $borrower_changes{'changed_fields'} || scalar @{$extended_attributes_changes} > 0 ) {
|
||||
( $template, $borrowernumber, $cookie ) = get_template_and_user(
|
||||
{
|
||||
template_name => "opac-memberentry-update-submitted.tt",
|
||||
|
|
@ -579,10 +579,8 @@ sub DelUnchangedFields {
|
|||
|
||||
|
||||
foreach my $key ( keys %new_data ) {
|
||||
next if defined($new_data{$key}) xor defined($current_data->{$key});
|
||||
if ( !defined($new_data{$key}) || $current_data->{$key} eq $new_data{$key} || $hidden_fields->{$key} ) {
|
||||
delete $new_data{$key};
|
||||
}
|
||||
next if ( ($new_data{$key} || $current_data->{$key}) && ( $new_data{$key} ne $current_data->{$key} ) && !($hidden_fields->{$key}) );
|
||||
delete $new_data{$key};
|
||||
}
|
||||
|
||||
return %new_data;
|
||||
|
|
|
|||
Loading…
Reference in New Issue