From 5949ad48c3e88584c84367756292cd8a927a4f83 Mon Sep 17 00:00:00 2001 From: Baptiste Wojtkowski Date: Thu, 30 Oct 2025 13:28:46 +0000 Subject: [PATCH] Bug 39721: fix suggestion_ref issues --- suggestion/suggestion.pl | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/suggestion/suggestion.pl b/suggestion/suggestion.pl index 8b329f6aa52..42f644de525 100755 --- a/suggestion/suggestion.pl +++ b/suggestion/suggestion.pl @@ -89,7 +89,9 @@ my $reasonsloop = GetAuthorisedValues("SUGGEST"); my $suggestion_ref = { $input->Vars }; my $stored_suggestion; -$stored_suggestion = Koha::Suggestions->find( $input->param('suggestionid') ) if $input->param('suggestionid'); +unless ( $op eq "cud-update_status" ) { + $stored_suggestion = Koha::Suggestions->find( $input->param('suggestionid') ) if $input->param('suggestionid'); +} delete $suggestion_ref->{$_} for qw(csrf_token suggestion_itemtype suggestion_managedby table_1_length); @@ -99,7 +101,14 @@ my $columns = ' ' . join( ' ', $schema->source('Suggestion')->columns ) my $suggestion_only = { map { $columns =~ / $_ / ? ( $_ => $suggestion_ref->{$_} ) : () } keys %$suggestion_ref }; $suggestion_only->{STATUS} = $suggestion_ref->{STATUS}; -qw( suggestedbyme op displayby tabcode notify filter_archived koha_login_context auth_forwarded_hash password userid ); +delete $$suggestion_ref{$_} + foreach + qw( suggestedbyme op displayby tabcode notify filter_archived koha_login_context auth_forwarded_hash password userid ); + +foreach my $key ( keys %$suggestion_ref ) { + delete $suggestion_ref->{$key} if ( !$suggestion_ref->{$key} && ( $op eq 'else' ) ); + delete $suggestion_ref->{$key} if $key =~ m{^DataTables_acqui_suggestions_suggestions}; +} delete $suggestion_only->{branchcode} if $suggestion_only->{branchcode} eq '__ANY__'; delete $suggestion_only->{budgetid} if $suggestion_only->{budgetid} eq '__ANY__'; @@ -247,6 +256,7 @@ if ( $op =~ /cud-save/ ) { # empty fields, to avoid filter in "SearchSuggestion" } + map { delete $$suggestion_ref{$_} unless $_ eq 'branchcode' } keys %$suggestion_ref; $op = 'else'; if ( $redirect eq 'purchase_suggestions' ) { -- 2.43.0