Bugzilla – Attachment 153646 Details for
Bug 25159
Action logs should be stored in JSON (and as a diff of the change)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25159: Implement diffs in action logs for holds
Bug-25159-Implement-diffs-in-action-logs-for-holds.patch (text/plain), 5.39 KB, created by
Kyle M Hall (khall)
on 2023-07-19 11:57:20 UTC
(
hide
)
Description:
Bug 25159: Implement diffs in action logs for holds
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2023-07-19 11:57:20 UTC
Size:
5.39 KB
patch
obsolete
>From d5c21e7ecd9ab2c5524425661e596f9e8f65a31b Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Tue, 18 Jul 2023 09:07:59 -0400 >Subject: [PATCH] Bug 25159: Implement diffs in action logs for holds > >Test Plan: >1) Apply this patch >2) Run updatedatabase.pl >3) Restart all the things! >4) Enable HoldsLog >5) Perform various hold related actions >6) Observe the diff column is populated by a JSON string > of the diff format generated by Struct::Diff > >Signed-off-by: Kyle Hall <kyle@bywatersolutions.com> >Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> >--- > C4/Reserves.pm | 19 ++++++++++++------- > Koha/Hold.pm | 16 ++++++++++++---- > 2 files changed, 24 insertions(+), 11 deletions(-) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 01aa726322..25adf0b5e6 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -1095,20 +1095,20 @@ sub ModReserve { > # FIXME Other calls may fail > Koha::Exceptions::ObjectNotFound->throw( 'No hold with id ' . $reserve_id ) unless $hold; > >+ my $original = C4::Context->preference('HoldsLog') ? $hold->unblessed : undef; >+ > if ( $rank eq "del" ) { > $hold->cancel({ cancellation_reason => $cancellation_reason }); > } > elsif ($hold->found && $hold->priority eq '0' && $date) { >- logaction( 'HOLDS', 'MODIFY', $hold->reserve_id, $hold ) >- if C4::Context->preference('HoldsLog'); > > # The only column that can be updated for a found hold is the expiration date > $hold->expirationdate($date)->store(); >+ >+ logaction( 'HOLDS', 'MODIFY', $hold->reserve_id, $hold, undef, $original ) >+ if C4::Context->preference('HoldsLog'); > } > elsif ($rank =~ /^\d+/ and $rank > 0) { >- logaction( 'HOLDS', 'MODIFY', $hold->reserve_id, $hold ) >- if C4::Context->preference('HoldsLog'); >- > my $properties = { > priority => $rank, > branchcode => $branchcode, >@@ -1135,7 +1135,10 @@ sub ModReserve { > } > } > >- _FixPriority({ reserve_id => $reserve_id, rank =>$rank }); >+ _FixPriority( { reserve_id => $reserve_id, rank => $rank } ); >+ >+ logaction( 'HOLDS', 'MODIFY', $hold->reserve_id, $hold, undef, $original ) >+ if C4::Context->preference('HoldsLog'); > } > } > >@@ -1209,6 +1212,8 @@ sub ModReserveAffect { > > return unless $hold; > >+ my $original = $hold->unblessed; >+ > my $already_on_shelf = $hold->found && $hold->found eq 'W'; > > $hold->itemnumber($itemnumber); >@@ -1249,7 +1254,7 @@ sub ModReserveAffect { > }); > $std->execute($hold->reserve_id); > >- logaction( 'HOLDS', 'MODIFY', $hold->reserve_id, $hold ) >+ logaction( 'HOLDS', 'MODIFY', $hold->reserve_id, $hold, undef, $original ) > if C4::Context->preference('HoldsLog'); > > return; >diff --git a/Koha/Hold.pm b/Koha/Hold.pm >index f275530d97..5ca7a9f853 100644 >--- a/Koha/Hold.pm >+++ b/Koha/Hold.pm >@@ -92,6 +92,8 @@ my $hold = $hold->suspend_hold( $suspend_until ); > sub suspend_hold { > my ( $self, $date ) = @_; > >+ my $original = C4::Context->preference('HoldsLog') ? $self->unblessed : undef; >+ > $date &&= dt_from_string($date)->truncate( to => 'day' )->datetime; > > if ( $self->is_found ) { # We can't suspend found holds >@@ -126,7 +128,7 @@ sub suspend_hold { > } > ); > >- logaction( 'HOLDS', 'SUSPEND', $self->reserve_id, $self ) >+ logaction( 'HOLDS', 'SUSPEND', $self->reserve_id, $self, undef, $original ) > if C4::Context->preference('HoldsLog'); > > Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( >@@ -147,6 +149,8 @@ my $hold = $hold->resume(); > sub resume { > my ( $self ) = @_; > >+ my $original = C4::Context->preference('HoldsLog') ? $self->unblessed : undef; >+ > $self->suspend(0); > $self->suspend_until( undef ); > >@@ -160,7 +164,7 @@ sub resume { > } > ); > >- logaction( 'HOLDS', 'RESUME', $self->reserve_id, $self ) >+ logaction( 'HOLDS', 'RESUME', $self->reserve_id, $self, undef, $original ) > if C4::Context->preference('HoldsLog'); > > Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( >@@ -669,6 +673,8 @@ sub cancel { > > my $autofill_next = $params->{autofill} && $self->itemnumber && $self->found && $self->found eq 'W'; > >+ my $original = C4::Context->preference('HoldsLog') ? $self->unblessed : undef; >+ > $self->_result->result_source->schema->txn_do( > sub { > my $patron = $self->patron; >@@ -741,7 +747,7 @@ sub cancel { > ); > } > >- C4::Log::logaction( 'HOLDS', 'CANCEL', $self->reserve_id, $self ) >+ C4::Log::logaction( 'HOLDS', 'CANCEL', $self->reserve_id, $self, undef, $original ) > if C4::Context->preference('HoldsLog'); > > Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( >@@ -781,6 +787,8 @@ sub fill { > sub { > my $patron = $self->patron; > >+ my $original = C4::Context->preference('HoldsLog') ? $self->unblessed : undef; >+ > $self->set( > { > found => 'F', >@@ -825,7 +833,7 @@ sub fill { > } > } > >- C4::Log::logaction( 'HOLDS', 'FILL', $self->id, $self ) >+ C4::Log::logaction( 'HOLDS', 'FILL', $self->id, $self, undef, $original ) > if C4::Context->preference('HoldsLog'); > > Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 25159
:
153600
|
153601
|
153602
|
153603
|
153604
|
153606
|
153607
|
153608
|
153609
|
153611
|
153612
|
153613
|
153614
|
153637
|
153643
|
153644
|
153645
|
153646
|
159758
|
164597
|
164598
|
164599
|
164600
|
164601
|
165527
|
165528
|
165529
|
165530
|
165531
|
165532
|
166219