Bugzilla – Attachment 170817 Details for
Bug 36474
updatetotalissues.pl should not modify the record when the total issues has not changed
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36474: Don't update records when total issues has not changed
Bug-36474-Dont-update-records-when-total-issues-ha.patch (text/plain), 3.84 KB, created by
Nick Clemens (kidclamp)
on 2024-08-28 13:29:46 UTC
(
hide
)
Description:
Bug 36474: Don't update records when total issues has not changed
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2024-08-28 13:29:46 UTC
Size:
3.84 KB
patch
obsolete
>From 705100e552e558caf433c1c3a1c652f6d45dd6fe Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Mon, 1 Apr 2024 15:00:34 +0000 >Subject: [PATCH] Bug 36474: Don't update records when total issues has not > changed > >This patch adds a new check in UpdateTotalIssues to check that we are changing the number >of total issues before calling ModBiblio > >To test: >0 - Enable CataloguingLog >1 - Checkout an item >2 - Run : misc/cronjobs/update_totalissues.pl --use-stats --commit=1000 -v >3 - In report, note all biblios were updated >4 - Check action_logs - note a new entry for every biblio >5 - Apply patch >6 - Repeat >7 - Note no biblios reported updated >8 - Note no new cataloguing log entries >9 - Checkout the item again >10 - Run again >11 - Note biblionumber has updated count in verbose output >12 - Note report only rpeort 1 biblio modified, the rest only processed >13 - Only one line added to action_logs >14 - Run it again >15 - Confirm no updates > >Signed-off-by: David Nind <david@davidnind.com> >--- > C4/Biblio.pm | 6 ++++-- > misc/cronjobs/update_totalissues.pl | 13 ++++++++----- > 2 files changed, 12 insertions(+), 7 deletions(-) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index 4b32ad43d52..3f48dbb8df4 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -3100,19 +3100,21 @@ sub UpdateTotalIssues { > $exception->rethrow unless ( $exception->isa('Koha::Exceptions::Metadata::Invalid') ); > warn $exception; > warn "UpdateTotalIssues could not get bibliographic record for biblionumber $biblionumber"; >- return; >+ return -1; > } > my $biblioitem = $biblio->biblioitem; > my ($totalissuestag, $totalissuessubfield) = GetMarcFromKohaField( 'biblioitems.totalissues' ); > unless ($totalissuestag) { >- return 1; # There is nothing to do >+ return 0; # There is nothing to do > } > >+ my $current_issues = $biblioitem->totalissues // 0; > if (defined $value) { > $totalissues = $value; > } else { > $totalissues = $biblioitem->totalissues + $increase; > } >+ return 0 if $current_issues == $totalissues; # No need to update if no changes > > my $field = $record->field($totalissuestag); > if (defined $field) { >diff --git a/misc/cronjobs/update_totalissues.pl b/misc/cronjobs/update_totalissues.pl >index 3e3a66b1f21..a5f7a5f5284 100755 >--- a/misc/cronjobs/update_totalissues.pl >+++ b/misc/cronjobs/update_totalissues.pl >@@ -98,7 +98,8 @@ my $dbh = C4::Context->dbh; > $dbh->{AutoCommit} = 0; > > my $num_bibs_processed = 0; >-my $num_bibs_error = 0; >+my $num_bibs_updated = 0; >+my $num_bibs_error = 0; > > my $starttime = time(); > >@@ -169,13 +170,14 @@ sub process_query { > my $ret; > if ( $incremental && $totalissues > 0 ) { > $ret = UpdateTotalIssues( $biblionumber, $totalissues, undef, 1 ); >- } >- else { >+ } else { > $ret = UpdateTotalIssues( $biblionumber, 0, $totalissues, 1 ); > } >- unless ($ret) { >+ if ( $ret == -1 ) { > print "Error while processing bib $biblionumber\n" if $verbose; > $num_bibs_error++; >+ } elsif ( $ret == 1 ) { >+ $num_bibs_updated++; > } > } > if ( not $test_only and ( $num_bibs_processed % $commit ) == 0 ) { >@@ -199,7 +201,8 @@ Update total issues count script report > Run started at: $starttime > Run ended at: $endtime > Total run time: $totaltime ms >-Number of bibs modified: $num_bibs_processed >+Number of bibs processed: $num_bibs_processed >+Number of bibs modified: $num_bibs_updated > Number of bibs with error: $num_bibs_error > _SUMMARY_ > $summary .= "\n**** Ran in test mode only ****\n" if $test_only; >-- >2.39.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 36474
:
164198
|
164241
|
170816
|
170817
|
171646
|
171647