Bugzilla – Attachment 116976 Details for
Bug 24469
Record biblionumber in import_biblio when adding to basket via file
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24469: Move the new queries to a dedicated ImportBatch subroutine
Bug-24469-Move-the-new-queries-to-a-dedicated-Impo.patch (text/plain), 6.92 KB, created by
Marcel de Rooy
on 2021-02-18 10:30:47 UTC
(
hide
)
Description:
Bug 24469: Move the new queries to a dedicated ImportBatch subroutine
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2021-02-18 10:30:47 UTC
Size:
6.92 KB
patch
obsolete
>From 729e90ec27f4727246aba76d35156a88b89304f1 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 12 Feb 2021 10:27:43 +0100 >Subject: [PATCH] Bug 24469: Move the new queries to a dedicated ImportBatch > subroutine >Content-Type: text/plain; charset=utf-8 > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Amended: POD line for $import_record_id. >--- > C4/ImportBatch.pm | 25 +++++++++++++++++++++---- > acqui/addorderiso2709.pl | 6 +----- > acqui/neworderempty.pl | 6 +----- > t/db_dependent/ImportBatch.t | 7 ++++++- > 4 files changed, 29 insertions(+), 15 deletions(-) > >diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm >index 9095aec4b5..2a5696d513 100644 >--- a/C4/ImportBatch.pm >+++ b/C4/ImportBatch.pm >@@ -78,6 +78,7 @@ BEGIN { > SetImportRecordOverlayStatus > GetImportRecordStatus > SetImportRecordStatus >+ SetMatchedBiblionumber > GetImportRecordMatches > SetImportRecordMatches > ); >@@ -631,7 +632,7 @@ sub BatchCommitRecords { > if ($record_type eq 'biblio') { > my $biblioitemnumber; > ($recordid, $biblioitemnumber) = AddBiblio($marc_record, $framework); >- $query = "UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?"; >+ $query = "UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?"; # FIXME call SetMatchedBiblionumber instead > if ($item_result eq 'create_new' || $item_result eq 'replace') { > my ($bib_items_added, $bib_items_replaced, $bib_items_errored) = BatchCommitItems($rowref->{'import_record_id'}, $recordid, $item_result); > $num_items_added += $bib_items_added; >@@ -664,7 +665,7 @@ sub BatchCommitRecords { > $oldxml = $old_marc->as_xml($marc_type); > > ModBiblio($marc_record, $recordid, $oldbiblio->frameworkcode); >- $query = "UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?"; >+ $query = "UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?"; # FIXME call SetMatchedBiblionumber instead > > if ($item_result eq 'create_new' || $item_result eq 'replace') { > my ($bib_items_added, $bib_items_replaced, $bib_items_errored) = BatchCommitItems($rowref->{'import_record_id'}, $recordid, $item_result); >@@ -697,7 +698,7 @@ sub BatchCommitRecords { > $num_items_errored += $bib_items_errored; > # still need to record the matched biblionumber so that the > # items can be reverted >- my $sth2 = $dbh->prepare_cached("UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?"); >+ my $sth2 = $dbh->prepare_cached("UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?"); # FIXME call SetMatchedBiblionumber instead > $sth2->execute($recordid, $rowref->{'import_record_id'}); > SetImportRecordOverlayStatus($rowref->{'import_record_id'}, 'match_applied'); > } >@@ -881,7 +882,7 @@ sub BatchRevertRecords { > my $query; > if ($record_type eq 'biblio') { > # remove matched_biblionumber only if there is no 'imported' item left >- $query = "UPDATE import_biblios SET matched_biblionumber = NULL WHERE import_record_id = ?"; >+ $query = "UPDATE import_biblios SET matched_biblionumber = NULL WHERE import_record_id = ?"; # FIXME Remove me > $query = "UPDATE import_biblios SET matched_biblionumber = NULL WHERE import_record_id = ? AND NOT EXISTS (SELECT * FROM import_items WHERE import_items.import_record_id=import_biblios.import_record_id and status='imported')"; > } else { > $query = "UPDATE import_auths SET matched_authid = NULL WHERE import_record_id = ?"; >@@ -1219,6 +1220,22 @@ sub SetImportBatchStatus { > > } > >+=head2 SetMatchedBiblionumber >+ >+ SetMatchedBiblionumber($import_record_id, $biblionumber); >+ >+=cut >+ >+sub SetMatchedBiblionumber { >+ my ($import_record_id, $biblionumber) = @_; >+ >+ my $dbh = C4::Context->dbh; >+ $dbh->do( >+ q|UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?|, >+ undef, $biblionumber, $import_record_id >+ ); >+} >+ > =head2 GetImportBatchOverlayAction > > my $overlay_action = GetImportBatchOverlayAction($batch_id); >diff --git a/acqui/addorderiso2709.pl b/acqui/addorderiso2709.pl >index 6783643d4f..0e3df3ba04 100755 >--- a/acqui/addorderiso2709.pl >+++ b/acqui/addorderiso2709.pl >@@ -199,11 +199,7 @@ if ($op eq ""){ > SetImportRecordStatus( $biblio->{'import_record_id'}, 'imported' ); > } > >- my $dbh = C4::Context->dbh; >- $dbh->do( >- q|UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?|, >- undef, $biblionumber, $biblio->{import_record_id} >- ); >+ SetMatchedBiblionumber( $biblio->{import_record_id}, $biblionumber ); > > # Add items from MarcItemFieldsToOrder > my @homebranches = $input->multi_param('homebranch_' . $biblio_count); >diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl >index 991dac517d..d95a5edd49 100755 >--- a/acqui/neworderempty.pl >+++ b/acqui/neworderempty.pl >@@ -180,11 +180,7 @@ if ( $ordernumber eq '' and defined $params->{'breedingid'}){ > $listprice = GetMarcPrice($marcrecord, $marcflavour); > SetImportRecordStatus($params->{'breedingid'}, 'imported'); > >- my $dbh = C4::Context->dbh; >- $dbh->do( >- q|UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?|, >- undef, $biblionumber, $params->{breedingid} >- ); >+ SetMatchedBiblionumber( $params->{breedingid}, $biblionumber ); > } > > >diff --git a/t/db_dependent/ImportBatch.t b/t/db_dependent/ImportBatch.t >index 863c903728..da0c1899b2 100755 >--- a/t/db_dependent/ImportBatch.t >+++ b/t/db_dependent/ImportBatch.t >@@ -1,7 +1,7 @@ > #!/usr/bin/perl > > use Modern::Perl; >-use Test::More tests => 15; >+use Test::More tests => 16; > use utf8; > use File::Basename; > use File::Temp qw/tempfile/; >@@ -134,6 +134,11 @@ my $record_from_import_biblio_without_items = C4::ImportBatch::GetRecordFromImpo > $original_record->leader($record_from_import_biblio_without_items->leader()); > is_deeply( $record_from_import_biblio_without_items, $original_record, 'GetRecordFromImportBiblio should return the record without items by default' ); > >+my $another_biblio = $builder->build_sample_biblio; >+C4::ImportBatch::SetMatchedBiblionumber( $import_record_id, $another_biblio->biblionumber ); >+my $import_biblios = GetImportBiblios( $import_record_id ); >+is( $import_biblios->[0]->{matched_biblionumber}, $another_biblio->biblionumber, 'SetMatchedBiblionumber should set the correct biblionumber' ); >+ > # Add a few tests for GetItemNumbersFromImportBatch > my @a = GetItemNumbersFromImportBatch( $id_import_batch1 ); > is( @a, 0, 'No item numbers expected since we did not commit' ); >-- >2.11.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 24469
:
98760
|
99073
|
102805
|
116255
|
116779
|
116792
|
116813
|
116975
| 116976