Bugzilla – Attachment 179840 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) using List::MoreUtils#any to get rid of %branches and fixing GetImportItemsBranches in ImportBatch.pm
Bug-21272-follow-up-using-ListMoreUtilsany-to-get-.patch (text/plain), 3.71 KB, created by
Hammat wele
on 2025-03-28 17:28:25 UTC
(
hide
)
Description:
Bug 21272: (follow-up) using List::MoreUtils#any to get rid of %branches and fixing GetImportItemsBranches in ImportBatch.pm
Filename:
MIME Type:
Creator:
Hammat wele
Created:
2025-03-28 17:28:25 UTC
Size:
3.71 KB
patch
obsolete
>From c0504ac5a07586c2ea07a3e3045b5e9b5916d996 Mon Sep 17 00:00:00 2001 >From: Hammat Wele <hammat.wele@inlibro.com> >Date: Thu, 9 Nov 2023 00:24:38 +0000 >Subject: [PATCH] Bug 21272: (follow-up) using List::MoreUtils#any to get rid > of %branches and fixing GetImportItemsBranches in ImportBatch.pm > >--- > C4/ImportBatch.pm | 13 ++++++------- > .../prog/en/modules/tools/manage-marc-import.tt | 2 +- > 2 files changed, 7 insertions(+), 8 deletions(-) > >diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm >index 42ea2594f5..002e2f6572 100644 >--- a/C4/ImportBatch.pm >+++ b/C4/ImportBatch.pm >@@ -41,7 +41,7 @@ use Koha::SearchEngine; > use Koha::SearchEngine::Indexer; > use Koha::Plugins::Handler; > use Koha::Logger; >-use List::MoreUtils qw( uniq ); >+use List::MoreUtils qw( uniq any ); > > our ( @ISA, @EXPORT_OK ); > >@@ -850,12 +850,11 @@ sub _batchCommitItems { > my ( $holdingbranchfield, $holdingbranchsubfield ) = GetMarcFromKohaField('items.holdingbranch'); > my $holdingbranch = $item_marc->subfield( $holdingbranchfield, $holdingbranchsubfield ); > >- my @branches = map { $_->branchcode } Koha::Libraries->search->as_list; >- my %branches = map { $_ => 1 } @branches; >+ my @branches = Koha::Libraries->search->as_list; > > my $missing_branchcode; >- $missing_branchcode = $homebranch if ( !exists( $branches{$homebranch} ) ); >- $missing_branchcode = $holdingbranch if ( !exists( $branches{$holdingbranch} ) ); >+ $missing_branchcode = $homebranch if not any { $_->branchcode eq $homebranch } @branches; >+ $missing_branchcode = $holdingbranch if not any { $_->branchcode eq $holdingbranch } @branches; > if ($missing_branchcode) { > $updsth->bind_param( 1, 'error' ); > $updsth->bind_param( 2, undef ); >@@ -1290,7 +1289,7 @@ sub GetImportItemsBranches { > ORDER BY import_items_id"; > my @params; > push( @params, $batch_id ); >- my $sth = $dbh->prepare_cached($query); >+ my $sth = $dbh->prepare($query); > $sth->execute(@params); > my $results = $sth->fetchall_arrayref( {} ); > my @branch; >@@ -1299,7 +1298,7 @@ sub GetImportItemsBranches { > foreach my $row (@$results) { > 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 );; >+ push @branch, $item_marc->subfield( $holdingbranchfield, $holdingbranchsubfield ); > } > $sth->finish(); > return uniq @branch; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt >index 7915227cd4..eda9c0ae23 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt >@@ -258,7 +258,7 @@ > <input type="submit" class="button" name="mainformsubmit" value="Import this batch into the catalog" /> > </fieldset> > [% IF ( missing_branches ) %] >- <div class="dialog alert">There are some missing libraries in your installation: >+ <div class="dialog alert"><span>There are some missing libraries in your installation:</span> > [% FOREACH branche IN branches %] > <a href="/cgi-bin/koha/admin/branches.pl?op=add_form" target="_blank"> > [% branche | html %] >-- >2.34.1
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