From 8ee4fef42ed62f1b377118bf1c67dfe8f90e131d Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 17 May 2024 08:46:30 -0400 Subject: [PATCH] Bug 35597: Move modification logging to Koha::Suggestion Some actions such as archiving a suggestion were not being logged. By moving the logging to Koha::Suggestion we can ensure more modifcations will be logged. Signed-off-by: Kyle M Hall Signed-off-by: Martin Renvoize --- C4/Suggestions.pm | 4 +--- Koha/Suggestion.pm | 11 +++++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm index 7ba21860d2..ed3a19bcfd 100644 --- a/C4/Suggestions.pm +++ b/C4/Suggestions.pm @@ -294,9 +294,7 @@ sub ModSuggestion { ) or warn "can't enqueue letter $letter"; } } - if ( C4::Context->preference("SuggestionsLog") ) { - logaction( 'SUGGESTION', 'MODIFY', $suggestion->{suggestionid}, $suggestion_object ); - } + return 1; # No useful if the exception is raised earlier } diff --git a/Koha/Suggestion.pm b/Koha/Suggestion.pm index 3ba4bf75e3..66c70e1277 100644 --- a/Koha/Suggestion.pm +++ b/Koha/Suggestion.pm @@ -73,6 +73,12 @@ sub store { my $new_suggestion = !$self->in_storage; my $result = $self->SUPER::store(); + + if ( C4::Context->preference("SuggestionsLog") ) { + my $action = $new_suggestion ? 'CREATE' : 'MODIFY'; + logaction( 'SUGGESTION', $action, $result->suggestionid, $self ); + } + if ( $emailpurchasesuggestions && $self->STATUS eq 'ASKED' ) { if ( @@ -114,10 +120,7 @@ sub store { ) or warn "can't enqueue letter $letter"; } } - my $suggestion_object = Koha::Suggestions->find( $result->suggestionid ); - if ( $new_suggestion && C4::Context->preference("SuggestionsLog") ) { - logaction( 'SUGGESTION', 'CREATE', $result->suggestionid, $suggestion_object ); - } + return $result; } -- 2.39.5