Bugzilla – Attachment 32629 Details for
Bug 12995
script update_totalissues.pl stops on corrupted record
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 12995 - script update_totalissues.pl stops on corrupted record
SIGNED-OFF-Bug-12995---script-updatetotalissuespl-.patch (text/plain), 4.43 KB, created by
Owen Leonard
on 2014-10-23 15:41:44 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 12995 - script update_totalissues.pl stops on corrupted record
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2014-10-23 15:41:44 UTC
Size:
4.43 KB
patch
obsolete
>From 40d7ab8ab99dbc5b01cfb7e6ab391a9f5b984a04 Mon Sep 17 00:00:00 2001 >From: Admin User Koha <koha@localhost> >Date: Mon, 20 Oct 2014 15:07:29 +0200 >Subject: [PATCH] [SIGNED-OFF] Bug 12995 - script update_totalissues.pl stops > on corrupted record >Content-Type: text/plain; charset="utf-8" > >When running update_totalissues.pl cronjob, it will stop on a corrupted >record. > >This patch changes UpdateTotalIssues so that it return 1 if processing >record has succeded. Also, if mapping with biblioitems.totalissues does >not exist, the method has nothing to do so it stops and returns 1. > >When processing a corrupted record, script now alerts about the error on >this biblionumber (if script is verbose) and process next record. >A total number of records with error will be printed at the end of the >script. > >Test plan : >- Create a dabase with a few biblios and some issues >- Modify first biblio record (use direct sql update) : set empty value > in biblioitems.marcxml >- Launch script : misc/cronjobs/update_totalissues.pl --use-stats --commit=1000 -v > >=> Without patch : the script stops at first record >=> With patch : the script prints error for first record and processes > all records > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> >I was able to confirm the problem before the patch and successfully >follow the test plan. >--- > C4/Biblio.pm | 19 ++++++++++++++----- > misc/cronjobs/update_totalissues.pl | 11 +++++++++-- > 2 files changed, 23 insertions(+), 7 deletions(-) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index ec4c71e..8bdb25f 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -3684,16 +3684,26 @@ sub UpdateTotalIssues { > my ($biblionumber, $increase, $value) = @_; > my $totalissues; > >+ my $record = GetMarcBiblio($biblionumber); >+ unless ($record) { >+ carp "UpdateTotalIssues could not get biblio record"; >+ return; >+ } > my $data = GetBiblioData($biblionumber); >+ unless ($data) { >+ carp "UpdateTotalIssues could not get datas of biblio"; >+ return; >+ } >+ my ($totalissuestag, $totalissuessubfield) = GetMarcFromKohaField('biblioitems.totalissues', $data->{'frameworkcode'}); >+ unless ($totalissuestag) { >+ return 1; # There is nothing to do >+ } > > if (defined $value) { > $totalissues = $value; > } else { > $totalissues = $data->{'totalissues'} + $increase; > } >- my ($totalissuestag, $totalissuessubfield) = GetMarcFromKohaField('biblioitems.totalissues', $data->{'frameworkcode'}); >- >- my $record = GetMarcBiblio($biblionumber); > > my $field = $record->field($totalissuestag); > if (defined $field) { >@@ -3704,8 +3714,7 @@ sub UpdateTotalIssues { > $record->insert_grouped_field($field); > } > >- ModBiblio($record, $biblionumber, $data->{'frameworkcode'}); >- return; >+ return ModBiblio($record, $biblionumber, $data->{'frameworkcode'}); > } > > =head2 RemoveAllNsb >diff --git a/misc/cronjobs/update_totalissues.pl b/misc/cronjobs/update_totalissues.pl >index 71da3aa..ba29225 100755 >--- a/misc/cronjobs/update_totalissues.pl >+++ b/misc/cronjobs/update_totalissues.pl >@@ -98,6 +98,7 @@ my $dbh = C4::Context->dbh; > $dbh->{AutoCommit} = 0; > > my $num_bibs_processed = 0; >+my $num_bibs_error = 0; > > my $starttime = time(); > >@@ -169,11 +170,16 @@ sub process_query { > print "Processing bib $biblionumber ($totalissues issues)\n" > if $verbose; > if ( not $test_only ) { >+ my $ret; > if ( $incremental && $totalissues > 0 ) { >- UpdateTotalIssues( $biblionumber, $totalissues ); >+ $ret = UpdateTotalIssues( $biblionumber, $totalissues ); > } > else { >- UpdateTotalIssues( $biblionumber, 0, $totalissues ); >+ $ret = UpdateTotalIssues( $biblionumber, 0, $totalissues ); >+ } >+ unless ($ret) { >+ print "Error while processing bib $biblionumber\n" if $verbose; >+ $num_bibs_error++; > } > } > if ( not $test_only and ( $num_bibs_processed % $commit ) == 0 ) { >@@ -198,6 +204,7 @@ Run started at: $starttime > Run ended at: $endtime > Total run time: $totaltime ms > Number of bibs modified: $num_bibs_processed >+Number of bibs with error: $num_bibs_error > _SUMMARY_ > $summary .= "\n**** Ran in test mode only ****\n" if $test_only; > print $summary; >-- >1.7.9.5
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 12995
:
31875
|
32454
|
32534
|
32535
|
32536
|
32629
|
32630
|
32654
|
32695
|
32696