Bugzilla – Attachment 180541 Details for
Bug 21272
MARC import should warn about mis-matched branch during staged import
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21272: (follow-up) tidy code
Bug-21272-follow-up-tidy-code.patch (text/plain), 5.49 KB, created by
Philip Orr
on 2025-04-03 13:52:33 UTC
(
hide
)
Description:
Bug 21272: (follow-up) tidy code
Filename:
MIME Type:
Creator:
Philip Orr
Created:
2025-04-03 13:52:33 UTC
Size:
5.49 KB
patch
obsolete
>From 298f9887d4604c7477cfe90c9962009d803699c7 Mon Sep 17 00:00:00 2001 >From: Hammat Wele <hammat.wele@inlibro.com> >Date: Tue, 4 Mar 2025 15:13:19 +0000 >Subject: [PATCH] Bug 21272: (follow-up) tidy code > >Signed-off-by: PhilipOrr <philip.orr@lmscloud.de> >--- > C4/ImportBatch.pm | 10 ++++++---- > t/db_dependent/ImportBatch.t | 23 +++++++++++++++++------ > tools/manage-marc-import.pl | 4 ++-- > 3 files changed, 25 insertions(+), 12 deletions(-) > >diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm >index fba7446ea4..3138bb17b2 100644 >--- a/C4/ImportBatch.pm >+++ b/C4/ImportBatch.pm >@@ -21,7 +21,7 @@ use strict; > use warnings; > > use C4::Context; >-use C4::Koha qw( GetNormalizedISBN ); >+use C4::Koha qw( GetNormalizedISBN ); > use C4::Biblio qw( > AddBiblio > DelBiblio >@@ -30,7 +30,7 @@ use C4::Biblio qw( > ModBiblio > TransformMarcToKoha > ); >-use C4::Items qw( AddItemFromMarc ModItemFromMarc ); >+use C4::Items qw( AddItemFromMarc ModItemFromMarc ); > use C4::Charset qw( MarcToUTF8Record SetUTF8Flag StripNonXmlChars ); > use C4::AuthoritiesMarc > qw( AddAuthority GuessAuthTypeCode GetAuthorityXML ModAuthority DelAuthority GetAuthorizedHeading ); >@@ -1281,7 +1281,7 @@ Returns an array of imported item branches. > =cut > > sub GetImportItemsBranches { >- my ( $batch_id ) = @_; >+ my ($batch_id) = @_; > > my $dbh = C4::Context->dbh; > my $query = "SELECT import_items_id, import_items.marcxml, encoding >@@ -1297,8 +1297,10 @@ sub GetImportItemsBranches { > my @branch; > my ( $homebranchfield, $homebranchsubfield ) = GetMarcFromKohaField('items.homebranch'); > my ( $holdingbranchfield, $holdingbranchsubfield ) = GetMarcFromKohaField('items.holdingbranch'); >+ > foreach my $row (@$results) { >- my $item_marc = MARC::Record->new_from_xml( StripNonXmlChars( $row->{'marcxml'} ), 'UTF-8', $row->{'encoding'} ); >+ my $item_marc = >+ MARC::Record->new_from_xml( StripNonXmlChars( $row->{'marcxml'} ), 'UTF-8', $row->{'encoding'} ); > push @branch, $item_marc->subfield( $homebranchfield, $homebranchsubfield ); > push @branch, $item_marc->subfield( $holdingbranchfield, $holdingbranchsubfield ); > } >diff --git a/t/db_dependent/ImportBatch.t b/t/db_dependent/ImportBatch.t >index 4718677d60..ab62187b63 100755 >--- a/t/db_dependent/ImportBatch.t >+++ b/t/db_dependent/ImportBatch.t >@@ -274,8 +274,11 @@ subtest "_batchCommitItems" => sub { > 'Error correctly set when import item has duplicate barcode and action always_add' > ); > >- $import_item = $builder->build_object({ class => 'Koha::Import::Record::Items', value => { >- marcxml => q{<?xml version="1.0" encoding="UTF-8"?> >+ $import_item = $builder->build_object( >+ { >+ class => 'Koha::Import::Record::Items', >+ value => { >+ marcxml => q{<?xml version="1.0" encoding="UTF-8"?> > <collection > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd" >@@ -293,14 +296,22 @@ subtest "_batchCommitItems" => sub { > </record> > </collection> > }, >- }}); >+ } >+ } >+ ); > > ( $num_items_added, $num_items_replaced, $num_items_errored ) = >- C4::ImportBatch::_batchCommitItems( $import_item->import_record_id, 32, 'always_add',64 ); >+ C4::ImportBatch::_batchCommitItems( $import_item->import_record_id, 32, 'always_add', 64 ); > is( $num_items_errored, 1, "Item with wrong branchcode fails when action always_add" ); > $import_item->discard_changes(); >- is( $import_item->status, 'error', "Import item marked as error when wrong branchcode detected and action always_add"); >- is( $import_item->import_error, 'Branch code WBRC missing', 'Error correctly set when import item has a wrong branchcode detected and action always_add' ); >+ is( >+ $import_item->status, 'error', >+ "Import item marked as error when wrong branchcode detected and action always_add" >+ ); >+ is( >+ $import_item->import_error, 'Branch code WBRC missing', >+ 'Error correctly set when import item has a wrong branchcode detected and action always_add' >+ ); > }; > > subtest "RecordsFromMarcPlugin" => sub { >diff --git a/tools/manage-marc-import.pl b/tools/manage-marc-import.pl >index 110e5bfb33..cfc56f9ebd 100755 >--- a/tools/manage-marc-import.pl >+++ b/tools/manage-marc-import.pl >@@ -28,7 +28,7 @@ use Try::Tiny; > # Koha modules used > use C4::Context; > use C4::Koha; >-use C4::Auth qw( get_template_and_user ); >+use C4::Auth qw( get_template_and_user ); > use C4::Output qw( output_html_with_http_headers ); > use C4::ImportBatch > qw( CleanBatch DeleteBatch GetImportBatch GetImportBatchOverlayAction GetImportBatchNoMatchAction GetImportBatchItemAction SetImportBatchOverlayAction SetImportBatchNoMatchAction SetImportBatchItemAction BatchFindDuplicates SetImportBatchMatcher GetItemNumbersFromImportBatch GetImportBatchRangeDesc GetNumberOfNonZ3950ImportBatches BatchCommitRecords BatchRevertRecords GetImportItemsBranches GetBadBranchesImportItems ); >@@ -96,7 +96,7 @@ if ( $op eq "" ) { > import_batches_list( $template, $offset, $results_per_page ); > } else { > my @import_items_branches = GetImportItemsBranches($import_batch_id); >- my @import_items = GetBadBranchesImportItems($import_batch_id); >+ my @import_items = GetBadBranchesImportItems($import_batch_id); > my @bad_item_titles; > my @missing_branches; > foreach my $item (@import_items) { >-- >2.39.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 21272
:
155038
|
155039
|
155043
|
155523
|
155524
|
155525
|
158683
|
163646
|
163648
|
164143
|
164147
|
164148
|
164149
|
178921
|
178922
|
178923
|
178924
|
178925
|
178926
|
178927
|
178928
|
179837
|
179838
|
179839
|
179840
|
179841
|
179842
|
179843
|
179844
|
180383
|
180534
|
180535
|
180536
|
180537
|
180538
|
180539
|
180540
| 180541 |
180542