Bugzilla – Attachment 170650 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.06 KB, created by
Phil Ringnalda
on 2024-08-23 15:38:41 UTC
(
hide
)
Description:
Bug 37550: CheckItemPreSave should run barcodes through barcodedecode
Filename:
MIME Type:
Creator:
Phil Ringnalda
Created:
2024-08-23 15:38:41 UTC
Size:
2.06 KB
patch
obsolete
>From 7e089ba2443969e3cff4b51c50666be426363cba 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> >--- > C4/Items.pm | 13 +++++++++---- > 1 file changed, 9 insertions(+), 4 deletions(-) > >diff --git a/C4/Items.pm b/C4/Items.pm >index 3041d8f13e..a91279b665 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 ); >@@ -459,11 +460,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.44.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 37550
:
169959
|
169960
|
169961
|
170630
|
170648
|
170649
|
170650
|
173868
|
173869
|
173870