Bugzilla – Attachment 173870 Details for
Bug 37550
bulkmarcimport.pl dies when adding items throws an exception
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37550: CheckItemPreSave should run barcodes through barcodedecode
Bug-37550-CheckItemPreSave-should-run-barcodes-thr.patch (text/plain), 2.12 KB, created by
Kyle M Hall (khall)
on 2024-11-01 12:18:52 UTC
(
hide
)
Description:
Bug 37550: CheckItemPreSave should run barcodes through barcodedecode
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2024-11-01 12:18:52 UTC
Size:
2.12 KB
patch
obsolete
>From 4bd4fd76792edcf0c9eaa72148c90be1b3cfbb9c Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Thu, 1 Aug 2024 18:01:25 +0000 >Subject: [PATCH] Bug 37550: CheckItemPreSave should run barcodes through > barcodedecode > >In Koha::Item we run a barcode through barcodedecode before any save. >We should do the same when checking barcodes to avoid a duplicate error >when the barcode is cleaned before it is written to the DB > >To test: >1 - Follow previous test plan >2 - Note that after this patch is applied there is no exception > All items are skipped as duplicate barcodes > >Signed-off-by: Phil Ringnalda <phil@chetcolibrary.org> >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > C4/Items.pm | 13 +++++++++---- > 1 file changed, 9 insertions(+), 4 deletions(-) > >diff --git a/C4/Items.pm b/C4/Items.pm >index 129a36f650c..be5a650c965 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -45,6 +45,7 @@ BEGIN { > } > > use Carp qw( croak ); >+use C4::Circulation qw( barcodedecode ); > use C4::Context; > use C4::Koha; > use C4::Biblio qw( GetMarcStructure TransformMarcToKoha ); >@@ -493,11 +494,15 @@ sub CheckItemPreSave { > my %errors = (); > > # check for duplicate barcode >- if (exists $item_ref->{'barcode'} and defined $item_ref->{'barcode'}) { >- my $existing_item= Koha::Items->find({barcode => $item_ref->{'barcode'}}); >+ if ( exists $item_ref->{'barcode'} and defined $item_ref->{'barcode'} ) { >+ my $barcode = C4::Circulation::barcodedecode( $item_ref->{'barcode'} ); >+ my $existing_item = Koha::Items->find( { barcode => $barcode } ); > if ($existing_item) { >- if (!exists $item_ref->{'itemnumber'} # new item >- or $item_ref->{'itemnumber'} != $existing_item->itemnumber) { # existing item >+ if ( >+ !exists $item_ref->{'itemnumber'} # new item >+ or $item_ref->{'itemnumber'} != $existing_item->itemnumber >+ ) >+ { # existing item > $errors{'duplicate_barcode'} = $item_ref->{'barcode'}; > } > } >-- >2.39.2
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 37550
:
169959
|
169960
|
169961
|
170630
|
170648
|
170649
|
170650
|
173868
|
173869
| 173870