Bug 42147: Log all relevant hold data on hold creation

When logging a hold create action, include all hold fields that may be
defined at hold creation.

Fields that are not defined until later (such as found status, waiting
date, etc) are not included to avoid clutter.

To test:
1. System preference setup
    i.  Enable HoldsLog system preference
    ii. Set AllowHoldPolicyOverride to Allow
2. Place a hold in the staff interface
3. View the action logs entry for that hold creation
    i. Go to Tools > Log viewer
    ii. Select Modules: Holds and Action: Create
    iii. Click Submit
--> Note that the "info" column only shows the hold id
4. Apply patch and restart_all
5. Repeat steps 2-3
--> The "info" column should now show hold details

Signed-off-by: Emmanuel Bétemps <e.betemps@gmail.com>
Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
This commit is contained in:
Emily Lamancusa 2026-03-23 10:24:23 -04:00 committed by Martin Renvoize
parent 5861ecdd0e
commit 83e2c3888d
No known key found for this signature in database
GPG Key ID: 2D86E0EAEC83711B
1 changed files with 24 additions and 14 deletions

View File

@ -264,20 +264,30 @@ sub AddReserve {
# Log the hold creation
if ( C4::Context->preference('HoldsLog') ) {
my $info = $hold->id;
if ( defined($confirmations) || defined($forced) ) {
$info = to_json(
{
hold => $hold->id,
branchcode => $hold->branchcode,
biblionumber => $hold->biblionumber,
itemnumber => $hold->itemnumber,
confirmations => $confirmations,
forced => $forced
},
{ pretty => 1, canonical => 1 }
);
}
my $info = to_json(
{
hold => $hold->id,
branchcode => $hold->branchcode,
biblionumber => $hold->biblionumber,
borrowernumber => $hold->borrowernumber,
itemnumber => $hold->itemnumber,
desk_id => $hold->desk_id,
hold_group_id => $hold->hold_group_id,
item_group_id => $hold->item_group_id,
item_level_hold => $hold->item_level_hold,
itemtype => $hold->itemtype,
lowestPriority => $hold->lowestPriority,
non_priority => $hold->non_priority,
patron_expiration_date => $hold->patron_expiration_date,
priority => $hold->priority,
reservenotes => $hold->reservenotes,
confirmations => $confirmations,
forced => $forced
},
{ pretty => 1, canonical => 1 }
);
logaction( 'HOLDS', 'CREATE', $hold->id, $info );
}