Bugzilla – Attachment 64892 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.71 KB, created by
Marcel de Rooy
on 2017-07-07 08:35:38 UTC
(
hide
)
Description:
Bug 18277: Remove GetBiblionumberFromItemnumber - Easy ones
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2017-07-07 08:35:38 UTC
Size:
7.71 KB
patch
obsolete
>From 5d411d377427a27a2d0be4847b0e4695a0af2cee 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 >Content-Type: text/plain; charset=utf-8 > >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. > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > C4/Acquisition.pm | 13 +++++++------ > C4/Items.pm | 3 ++- > C4/Record.pm | 4 +++- > Koha/REST/V1/Hold.pm | 14 +++++++++----- > cataloguing/additem.pl | 4 +++- > opac/opac-reserve.pl | 3 ++- > tools/batchMod.pl | 6 +++++- > 7 files changed, 31 insertions(+), 16 deletions(-) > >diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm >index b3b72b9..5e1e651 100644 >--- a/C4/Acquisition.pm >+++ b/C4/Acquisition.pm >@@ -31,6 +31,7 @@ use Koha::DateUtils qw( dt_from_string output_pref ); > use Koha::Acquisition::Order; > use Koha::Acquisition::Booksellers; > use Koha::Biblios; >+use Koha::Items; > use Koha::Number::Price; > use Koha::Libraries; > use Koha::CsvProfiles; >@@ -1660,17 +1661,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 26c14a1..2e5fbc7 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -665,7 +665,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 d72e5df..99af461 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,21 @@ 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; >+ $biblio->unblessed; # FIXME remove later >+ } else { >+ $biblio = C4::Biblio::GetBiblio($biblionumber); > } > >- my $biblio = C4::Biblio::GetBiblio($biblionumber); >- > my $can_reserve = > $itemnumber > ? CanItemBeReserved( $borrowernumber, $itemnumber ) >diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl >index c986b19..03adf46 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::ItemTypes; > use Koha::Libraries; > use List::MoreUtils qw/any/; >@@ -794,9 +795,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 9ddbb26..44d6c94 100755 >--- a/opac/opac-reserve.pl >+++ b/opac/opac-reserve.pl >@@ -244,7 +244,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 1dc2174..7c87c7f 100755 >--- a/tools/batchMod.pl >+++ b/tools/batchMod.pl >@@ -37,6 +37,7 @@ use List::MoreUtils qw/uniq/; > > use Koha::Biblios; > use Koha::DateUtils; >+use Koha::Items; > use Koha::ItemTypes; > > my $input = new CGI; >@@ -121,7 +122,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.1.4
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