Bugzilla – Attachment 77589 Details for
Bug 21184
C4::Items - Remove GetBarcodeFromItemnumber
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21184: Replace C4::Items::GetBarcodeFromItemnumber calls
Bug-21184-Replace-C4ItemsGetBarcodeFromItemnumber-.patch (text/plain), 4.16 KB, created by
Jonathan Druart
on 2018-08-08 18:56:29 UTC
(
hide
)
Description:
Bug 21184: Replace C4::Items::GetBarcodeFromItemnumber calls
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2018-08-08 18:56:29 UTC
Size:
4.16 KB
patch
obsolete
>From 7385d2c2700128cf967f9c13ce45a55660cb71d1 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 6 Aug 2018 15:59:38 -0300 >Subject: [PATCH] Bug 21184: Replace C4::Items::GetBarcodeFromItemnumber calls > >Those calls to C4::Items::GetBarcodeFromItemnumber can be replaced with > my $barcode = Koha::Items->find($itemnumber)->barcode; >But if we are not sure that the item exists, we should test the return >of ->find before ->barcode > >Test plan: >- Edit an item >- Check an item in > >- Test SIP - I do not really know how to trigger that code, apparently >misc/sip_cli_emulator.pl does not deal with holds. Any ideas? >--- > C4/SIP/ILS/Patron.pm | 15 ++++++++++----- > cataloguing/additem.pl | 4 +++- > svc/checkin | 7 +++++-- > 3 files changed, 18 insertions(+), 8 deletions(-) > >diff --git a/C4/SIP/ILS/Patron.pm b/C4/SIP/ILS/Patron.pm >index 23c576493f..cee3bac40b 100644 >--- a/C4/SIP/ILS/Patron.pm >+++ b/C4/SIP/ILS/Patron.pm >@@ -22,9 +22,10 @@ use C4::Context; > use C4::Koha; > use C4::Members; > use C4::Reserves; >-use C4::Items qw( GetBarcodeFromItemnumber GetItemnumbersForBiblio); >+use C4::Items qw( GetItemnumbersForBiblio); > use C4::Auth qw(checkpw); > >+use Koha::Items; > use Koha::Libraries; > use Koha::Patrons; > >@@ -315,7 +316,8 @@ sub hold_items { > my $self = shift; > my $item_arr = $self->x_items('hold_items', @_); > foreach my $item (@{$item_arr}) { >- $item->{barcode} = GetBarcodeFromItemnumber($item->{itemnumber}); >+ my $item = Koha::Items->find($item->{itemnumber}); >+ $item->{barcode} = $item ? $item->barcode : undef; > } > return $item_arr; > } >@@ -483,15 +485,18 @@ sub _get_outstanding_holds { > while ( my $hold = $holds->next ) { > my $item; > if ($hold->itemnumber) { >- $item = $hold->itemnumber; >+ $item = $hold->item; > } > else { > # We need to return a barcode for the biblio so the client > # can request the biblio info >- $item = ( GetItemnumbersForBiblio($hold->biblionumber) )->[0]; >+ my $items = $hold->biblio->items; >+ $item = $items->count ? $item->next : undef; > } > my $unblessed_hold = $hold->unblessed; >- $unblessed_hold->{barcode} = GetBarcodeFromItemnumber($item); >+ >+ $unblessed_hold->{barcode} = $item ? $item->barcode : undef; >+ > push @holds, $unblessed_hold; > } > return \@holds; >diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl >index 52f56b6b7a..01cc407da5 100755 >--- a/cataloguing/additem.pl >+++ b/cataloguing/additem.pl >@@ -903,6 +903,8 @@ foreach my $tag ( keys %{$tagslib}){ > } > @loop_data = sort {$a->{subfield} cmp $b->{subfield} } @loop_data; > >+my $item = Koha::Items->find($itemnumber); # We certainly want to fetch it earlier >+ > # what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit. > $template->param( > biblionumber => $biblionumber, >@@ -912,7 +914,7 @@ $template->param( > item_header_loop => \@header_value_loop, > item => \@loop_data, > itemnumber => $itemnumber, >- barcode => GetBarcodeFromItemnumber($itemnumber), >+ barcode => $item ? $item->barcode : undef, > itemtagfield => $itemtagfield, > itemtagsubfield => $itemtagsubfield, > op => $nextop, >diff --git a/svc/checkin b/svc/checkin >index 78db9d923d..9b72abaa79 100755 >--- a/svc/checkin >+++ b/svc/checkin >@@ -24,10 +24,11 @@ use CGI; > use JSON qw(to_json); > > use C4::Circulation; >-use C4::Items qw(GetBarcodeFromItemnumber GetItem ModItem); >+use C4::Items qw(GetItem ModItem); > use C4::Context; > use C4::Auth qw(check_cookie_auth); > use Koha::Checkouts; >+use Koha::Items; > > my $input = new CGI; > >@@ -53,7 +54,9 @@ my $branchcode = $input->param('branchcode') > $override_limit = $override_limit ? $override_limit eq 'true' : undef; > $exempt_fine = $exempt_fine ? $exempt_fine eq 'true' : undef; > >-my $barcode = GetBarcodeFromItemnumber($itemnumber); >+my $item = Koha::Items->find($itemnumber); >+ >+my $barcode = $item ? $item->barcode : undef; # We certainly will want to return an error code > > my $data; > $data->{itemnumber} = $itemnumber; >-- >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 21184
:
77589
|
77590
|
77955
|
77956
|
77961
|
77962
|
77963
|
78111
|
78112
|
78113