Bugzilla – Attachment 61127 Details for
Bug 18277
Koha::Biblio - Remove GetBiblionumberFromItemnumber
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18277: Remove GetBiblionumberFromItemnumber - Easy ones
Bug-18277-Remove-GetBiblionumberFromItemnumber---E.patch (text/plain), 7.95 KB, created by
Jonathan Druart
on 2017-03-15 19:53:31 UTC
(
hide
)
Description:
Bug 18277: Remove GetBiblionumberFromItemnumber - Easy ones
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2017-03-15 19:53:31 UTC
Size:
7.95 KB
patch
obsolete
>From 406b148015528b59c18875f1dd1b232393828266 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 15 Mar 2017 12:28:13 -0300 >Subject: [PATCH] Bug 18277: Remove GetBiblionumberFromItemnumber - Easy ones > >To retrieve a biblionumber from an itemnumber, we can use: > Koha::Item->biblio->biblionumber > >This is only what this patchset does. >Doing that we will be able to get rid of the >C4::Biblio::GetBiblionumberFromItemnumber subroutine. > >Test plan: >- Acquisition module: cancel a receipt >- Export a record to CSV >- Modify items in a batch > >Item's info should be correct > >Other changes with be checked by QA team, by reading the code. >--- > C4/Acquisition.pm | 13 +++++++------ > C4/Items.pm | 3 ++- > C4/Record.pm | 4 +++- > Koha/REST/V1/Hold.pm | 13 +++++++------ > cataloguing/additem.pl | 4 +++- > opac/opac-reserve.pl | 4 +++- > tools/batchMod.pl | 6 +++++- > 7 files changed, 30 insertions(+), 17 deletions(-) > >diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm >index c113c16..a02c1f0 100644 >--- a/C4/Acquisition.pm >+++ b/C4/Acquisition.pm >@@ -30,6 +30,7 @@ use C4::Templates qw(gettemplate); > use Koha::DateUtils qw( dt_from_string output_pref ); > use Koha::Acquisition::Order; > use Koha::Acquisition::Booksellers; >+use Koha::Items; > use Koha::Number::Price; > use Koha::Libraries; > >@@ -1605,17 +1606,17 @@ sub CancelReceipt { > my @affects = split q{\|}, C4::Context->preference("AcqItemSetSubfieldsWhenReceiptIsCancelled"); > if ( @affects ) { > for my $in ( @itemnumbers ) { >- my $biblionumber = C4::Biblio::GetBiblionumberFromItemnumber( $in ); >- my $frameworkcode = GetFrameworkCode($biblionumber); >- my ( $itemfield ) = GetMarcFromKohaField( 'items.itemnumber', $frameworkcode ); >- my $item = C4::Items::GetMarcItem( $biblionumber, $in ); >+ my $item = Koha::Items->find( $in ); >+ my $biblio = $item->biblio; >+ my ( $itemfield ) = GetMarcFromKohaField( 'items.itemnumber', $biblio->frameworkcode ); >+ my $item_marc = C4::Items::GetMarcItem( $biblio->biblionumber, $in ); > for my $affect ( @affects ) { > my ( $sf, $v ) = split q{=}, $affect, 2; >- foreach ( $item->field($itemfield) ) { >+ foreach ( $item_marc->field($itemfield) ) { > $_->update( $sf => $v ); > } > } >- C4::Items::ModItemFromMarc( $item, $biblionumber, $in ); >+ C4::Items::ModItemFromMarc( $item_marc, $biblio->biblionumber, $in ); > } > } > } >diff --git a/C4/Items.pm b/C4/Items.pm >index 8f177b0..2900ecc 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -671,7 +671,8 @@ sub DelItem { > my $biblionumber = $params->{biblionumber}; > > unless ($biblionumber) { >- $biblionumber = C4::Biblio::GetBiblionumberFromItemnumber($itemnumber); >+ my $item = Koha::Items->find( $itemnumber ); >+ $biblionumber = $item->biblio->biblionumber; > } > > # If there is no biblionumber for the given itemnumber, there is nothing to delete >diff --git a/C4/Record.pm b/C4/Record.pm >index abc0075..e36e035 100644 >--- a/C4/Record.pm >+++ b/C4/Record.pm >@@ -34,6 +34,7 @@ use C4::XSLT (); > use YAML; #marcrecords2csv > use Template; > use Text::CSV::Encoded; #marc2csv >+use Koha::Items; > use Koha::SimpleMARC qw(read_field); > use Koha::XSLT_Handler; > use Koha::CsvProfiles; >@@ -427,7 +428,8 @@ sub marc2csv { > my $firstpass = 1; > if ( @$itemnumbers ) { > for my $itemnumber ( @$itemnumbers) { >- my $biblionumber = GetBiblionumberFromItemnumber $itemnumber; >+ my $item = Koha::Items->find( $itemnumber ); >+ my $biblionumber = $item->biblio->biblionumber; > $output .= marcrecord2csv( $biblionumber, $id, $firstpass, $csv, $fieldprocessing, [$itemnumber] ); > $firstpass = 0; > } >diff --git a/Koha/REST/V1/Hold.pm b/Koha/REST/V1/Hold.pm >index 7f0b1ff..6c2a079 100644 >--- a/Koha/REST/V1/Hold.pm >+++ b/Koha/REST/V1/Hold.pm >@@ -22,6 +22,7 @@ use Mojo::Base 'Mojolicious::Controller'; > use C4::Biblio; > use C4::Reserves; > >+use Koha::Items; > use Koha::Patrons; > use Koha::Holds; > use Koha::DateUtils; >@@ -65,18 +66,18 @@ sub add { > }, 400); > } > >+ my $biblio; > if ($itemnumber) { >- my $item_biblionumber = C4::Biblio::GetBiblionumberFromItemnumber($itemnumber); >- if ($biblionumber and $biblionumber != $item_biblionumber) { >+ my $item = Koha::Items->find( $itemnumber ); >+ $biblio = $item->biblio; >+ if ($biblionumber and $biblionumber != $biblio->biblionumber) { > return $c->$cb({ > error => "Item $itemnumber doesn't belong to biblio $biblionumber" > }, 400); > } >- $biblionumber ||= $item_biblionumber; >+ $biblionumber ||= $biblio->biblionumber; > } > >- my $biblio = C4::Biblio::GetBiblio($biblionumber); >- > my $can_reserve = > $itemnumber > ? CanItemBeReserved( $borrowernumber, $itemnumber ) >@@ -98,7 +99,7 @@ sub add { > > my $reserve_id = C4::Reserves::AddReserve($branchcode, $borrowernumber, > $biblionumber, undef, $priority, undef, $expirationdate, undef, >- $biblio->{title}, $itemnumber); >+ $biblio->title, $itemnumber); > > unless ($reserve_id) { > return $c->$cb({ >diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl >index 5d8c0d0..f081d57 100755 >--- a/cataloguing/additem.pl >+++ b/cataloguing/additem.pl >@@ -31,6 +31,7 @@ use C4::Circulation; > use C4::Koha; > use C4::ClassSource; > use Koha::DateUtils; >+use Koha::Items; > use Koha::Libraries; > use List::MoreUtils qw/any/; > use C4::Search; >@@ -806,9 +807,10 @@ foreach my $field (@fields) { > > if ( C4::Context->preference('EasyAnalyticalRecords') ) { > foreach my $hostitemnumber (@hostitemnumbers){ >+ my $item = Koha::Items->find( $hostitemnumber ); > if ($this_row{itemnumber} eq $hostitemnumber){ > $this_row{hostitemflag} = 1; >- $this_row{hostbiblionumber}= GetBiblionumberFromItemnumber($hostitemnumber); >+ $this_row{hostbiblionumber}= $item->biblio->biblionumber; > last; > } > } >diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl >index e304066..69abdcc 100755 >--- a/opac/opac-reserve.pl >+++ b/opac/opac-reserve.pl >@@ -33,6 +33,7 @@ use C4::Members; > use C4::Overdues; > use C4::Debug; > use Koha::DateUtils; >+use Koha::Items; > use Koha::Libraries; > use Koha::Patrons; > use Date::Calc qw/Today Date_to_Days/; >@@ -241,7 +242,8 @@ if ( $query->param('place_reserve') ) { > > #item may belong to a host biblio, if yes change biblioNum to hosts bilbionumber > if ( $itemNum ne '' ) { >- my $hostbiblioNum = GetBiblionumberFromItemnumber($itemNum); >+ my $item = Koha::Items->find( $itemNum ); >+ my $hostbiblioNum = $item->biblio->biblionumber; > if ( $hostbiblioNum ne $biblioNum ) { > $biblioNum = $hostbiblioNum; > } >diff --git a/tools/batchMod.pl b/tools/batchMod.pl >index 2920da9..366f2d3 100755 >--- a/tools/batchMod.pl >+++ b/tools/batchMod.pl >@@ -35,6 +35,7 @@ use C4::Members; > use MARC::File::XML; > use List::MoreUtils qw/uniq/; > use Koha::DateUtils; >+use Koha::Items; > > my $input = new CGI; > my $dbh = C4::Context->dbh; >@@ -118,7 +119,10 @@ if ($op eq "action") { > $items_display_hashref=BuildItemsData(@itemnumbers); > } else { > # Else, we only display the barcode >- my @simple_items_display = map {{ itemnumber => $_, barcode => (GetBarcodeFromItemnumber($_) or ""), biblionumber => (GetBiblionumberFromItemnumber($_) or "") }} @itemnumbers; >+ my @simple_items_display = map { >+ my $itemnumber = $_; >+ my $item = Koha::Items->find($itemnumber); >+ { itemnumber => $itemnumber, barcode => ($item->barcode || q||), biblionumber => $item->biblio->biblionumber }} @itemnumbers; > $template->param("simple_items_display" => \@simple_items_display); > } > >-- >2.9.3
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 18277
:
61127
|
61128
|
61129
|
61130
|
63301
|
63302
|
63303
|
63304
|
64819
|
64820
|
64821
|
64822
|
64892
|
64893
|
64894
|
64895
|
64896