Bug 35491: Add logging to RevertWaitingStatus

This patch simply adds a logaction line to RevertWaitingStatus

To test:
1 - Enable HoldsLog
2 - Place a hold
3 - Fill the hold
4 - Revert the waiting status
5 - Note there is no action log added
6 - Apply patch
7 - Repeat 2-4
8 - Confirm you now have a MODIFY action logged for the reversion

Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 4e42f1182d)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit 5ca5900f91)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Nick Clemens 2023-12-05 16:27:44 +00:00 committed by Lucas Gass
parent 0b1a1261ff
commit 993931eb9e
2 changed files with 24 additions and 6 deletions

View file

@ -2120,6 +2120,9 @@ sub RevertWaitingStatus {
}
)->store();
logaction( 'HOLDS', 'MODIFY', $hold->id, $hold )
if C4::Context->preference('HoldsLog');
_FixPriority( { biblionumber => $hold->biblionumber } );
Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue(

View file

@ -1004,7 +1004,7 @@ subtest 'reserves.item_level_hold' => sub {
);
subtest 'item level hold' => sub {
plan tests => 3;
plan tests => 5;
my $reserve_id = AddReserve(
{
branchcode => $item->homebranch,
@ -1032,24 +1032,39 @@ subtest 'reserves.item_level_hold' => sub {
} );
t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 1 );
t::lib::Mocks::mock_preference( 'HoldsLog', 1 );
# Revert the waiting status
C4::Reserves::RevertWaitingStatus(
{ itemnumber => $item->itemnumber } );
C4::Reserves::RevertWaitingStatus( { itemnumber => $item->itemnumber } );
$hold = Koha::Holds->find($reserve_id);
is( $hold->itemnumber, $item->itemnumber, 'Itemnumber should not be removed when the waiting status is revert' );
is(
$hold->itemnumber, $item->itemnumber,
'Itemnumber should not be removed when the waiting status is revert'
);
my $log =
Koha::ActionLogs->search( { module => 'HOLDS', action => 'MODIFY', object => $hold->reserve_id } )->next;
my $expected = sprintf q{'timestamp' => '%s'}, $hold->timestamp;
like( $log->info, qr{$expected}, 'Timestamp logged is the current one' );
my $log_count =
Koha::ActionLogs->search( { module => 'HOLDS', action => 'MODIFY', object => $hold->reserve_id } )->count;
t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 );
t::lib::Mocks::mock_preference( 'HoldsLog', 0 );
$hold->set_waiting;
# Revert the waiting status, RealTimeHoldsQueue => shouldn't add a test
C4::Reserves::RevertWaitingStatus(
{ itemnumber => $item->itemnumber } );
C4::Reserves::RevertWaitingStatus( { itemnumber => $item->itemnumber } );
$hold->delete; # cleanup
my $log_count_after =
Koha::ActionLogs->search( { module => 'HOLDS', action => 'MODIFY', object => $hold->reserve_id } )->count;
is( $log_count, $log_count_after, "No logging is added for RevertWaitingStatus when HoldsLog is disabled" );
};
subtest 'biblio level hold' => sub {