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; }