From f55519b50526cb6957fcaa5967cce3e7b1ebe64c Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 12 Aug 2024 10:15:20 +0100 Subject: [PATCH] Bug 36758: (follow-up) Fix unit tests We do two things here.. * We're making the improvement to C4::Letters that sets librarian to a patron object more resilient by testing for the userenv first. * We correct the logic in Koha::Ticket such that we always store changes when there's a ticket update Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer --- C4/Letters.pm | 3 ++- Koha/Ticket.pm | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/C4/Letters.pm b/C4/Letters.pm index 497b97dab9..3f2fc95a4b 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -626,7 +626,8 @@ sub GetPreparedLetter { return; my $want_librarian = $params{want_librarian}; if ($want_librarian) { - $objects->{librarian} = Koha::Patrons->find( C4::Context->userenv->{number} ); + my $userenv = C4::Context->userenv; + $objects->{librarian} = Koha::Patrons->find( C4::Context->userenv->{number} ) if ($userenv); } # Best guess at language 'default' notice is written for include handling diff --git a/Koha/Ticket.pm b/Koha/Ticket.pm index eb2580032e..18f9c672a3 100644 --- a/Koha/Ticket.pm +++ b/Koha/Ticket.pm @@ -176,7 +176,8 @@ sub store { } } else { my %updated_columns = $self->_result->get_dirty_columns; - return $self->SUPER::store unless %updated_columns; + $self->SUPER::store; + $self->discard_changes; $assignee = ( exists $updated_columns{assignee_id} ) ? $self->assignee : undef; } -- 2.39.5