Bugzilla – Attachment 41215 Details for
Bug 10961
Error in GetMarcBiblio can cause severe data loss
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PASSED QA] Bug 10961: (followup) Make query fields explicit and add regression tests
PASSED-QA-Bug-10961-followup-Make-query-fields-exp.patch (text/plain), 4.07 KB, created by
Tomás Cohen Arazi (tcohen)
on 2015-07-28 13:10:26 UTC
(
hide
)
Description:
[PASSED QA] Bug 10961: (followup) Make query fields explicit and add regression tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2015-07-28 13:10:26 UTC
Size:
4.07 KB
patch
obsolete
>From 0011f896f6e60365ea7c20669b8a85878ba07851 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?St=C3=A9phane=20Delaune?= <stephane.delaune@biblibre.com> >Date: Thu, 23 Jul 2015 16:28:57 +0200 >Subject: [PATCH] [PASSED QA] Bug 10961: (followup) Make query fields explicit > and add regression tests > >add correct frameworkcode to _koha_marc_update_bib_ids parameters > >add test, prove with : prove t/db_dependent/Biblio.t > >TEST PLAN >--------- >1) git checkout -b bug_10961 origin/master >2) git bz apply 10961 >3) git checkout origin/master -- C4/Biblio.pm >4) prove t/db_dependent/Biblio.t > -- was expecting failure, got failure. >5) git reset --hard origin/master >6) git bz apply 10961 >7) prove t/db_dependent/Biblio.t > -- success as expected. >8) Read over code. > -- Noted it also grabs the framework code for the biblio, rather than uses default. > And it also corrects an indentation issue. > Test case looks like it attempts to cover the biblionumber!=biblioitemnumber case > by adding 1. >9) run koha qa test tools. > >Signed-off-by: Mark Tompsett <mtompset@hotmail.com> >Signed-off-by: Tomas Cohen Arazi <tomascohen@unc.edu.ar> >--- > C4/Biblio.pm | 6 ++++-- > t/db_dependent/Biblio.t | 19 ++++++++++++++++--- > 2 files changed, 20 insertions(+), 5 deletions(-) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index 533932b..d90094e 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -1268,10 +1268,12 @@ sub GetMarcBiblio { > } > > my $dbh = C4::Context->dbh; >- my $sth = $dbh->prepare("SELECT * FROM biblioitems WHERE biblionumber=? "); >+ my $sth = $dbh->prepare("SELECT biblioitemnumber, marcxml FROM biblioitems WHERE biblionumber=? "); > $sth->execute($biblionumber); > my $row = $sth->fetchrow_hashref; >+ my $biblioitemnumber = $row->{'biblioitemnumber'}; > my $marcxml = StripNonXmlChars( $row->{'marcxml'} ); >+ my $frameworkcode = GetFrameworkCode($biblionumber); > MARC::File::XML->default_record_format( C4::Context->preference('marcflavour') ); > my $record = MARC::Record->new(); > >@@ -1280,7 +1282,7 @@ sub GetMarcBiblio { > if ($@) { warn " problem with :$biblionumber : $@ \n$marcxml"; } > return unless $record; > >- C4::Biblio::_koha_marc_update_bib_ids($record, '', $biblionumber, $row->{biblioitemnumber}); >+ C4::Biblio::_koha_marc_update_bib_ids($record, $frameworkcode, $biblionumber, $biblioitemnumber); > C4::Biblio::EmbedItemsInMarcBiblio($record, $biblionumber) if ($embeditems); > > return $record; >diff --git a/t/db_dependent/Biblio.t b/t/db_dependent/Biblio.t >index f53b6a5..0413b90 100755 >--- a/t/db_dependent/Biblio.t >+++ b/t/db_dependent/Biblio.t >@@ -194,6 +194,19 @@ sub run_tests { > > is( GetMarcPrice( $record_for_isbn, $marcflavour ), 100, > "GetMarcPrice returns the correct value"); >+ my $newincbiblioitemnumber=$biblioitemnumber+1; >+ $dbh->do("UPDATE biblioitems SET biblioitemnumber = ? WHERE biblionumber = ?;", undef, $newincbiblioitemnumber, $biblionumber ); >+ my $updatedrecord = GetMarcBiblio($biblionumber, 0); >+ my $frameworkcode = GetFrameworkCode($biblionumber); >+ my ( $biblioitem_tag, $biblioitem_subfield ) = GetMarcFromKohaField( "biblioitems.biblioitemnumber", $frameworkcode ); >+ die qq{No biblioitemnumber tag for framework "$frameworkcode"} unless $biblioitem_tag; >+ my $biblioitemnumbertotest; >+ if ( $biblioitem_tag < 10 ) { >+ $biblioitemnumbertotest = $updatedrecord->field($biblioitem_tag)->data(); >+ } else { >+ $biblioitemnumbertotest = $updatedrecord->field($biblioitem_tag)->subfield($biblioitem_subfield); >+ } >+ is ($newincbiblioitemnumber, $biblioitemnumbertotest); > } > > sub mock_marcfromkohafield { >@@ -260,19 +273,19 @@ sub create_issn_field { > } > > subtest 'MARC21' => sub { >- plan tests => 27; >+ plan tests => 28; > run_tests('MARC21'); > $dbh->rollback; > }; > > subtest 'UNIMARC' => sub { >- plan tests => 27; >+ plan tests => 28; > run_tests('UNIMARC'); > $dbh->rollback; > }; > > subtest 'NORMARC' => sub { >- plan tests => 27; >+ plan tests => 28; > run_tests('NORMARC'); > $dbh->rollback; > }; >-- >2.5.0
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 10961
:
21520
|
41130
|
41182
|
41183
|
41214
| 41215