Bugzilla – Attachment 77685 Details for
Bug 21201
C4::Items - Remove GetItemnumbersForBiblio
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21201: Replace C4::Items::GetItemnumbersForBiblio calls
Bug-21201-Replace-C4ItemsGetItemnumbersForBiblio-c.patch (text/plain), 5.58 KB, created by
Jonathan Druart
on 2018-08-10 14:59:50 UTC
(
hide
)
Description:
Bug 21201: Replace C4::Items::GetItemnumbersForBiblio calls
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2018-08-10 14:59:50 UTC
Size:
5.58 KB
patch
obsolete
>From d276c12950eff1efdfbc0fbc2e2603958e97bdae Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 6 Aug 2018 16:40:44 -0300 >Subject: [PATCH] Bug 21201: Replace C4::Items::GetItemnumbersForBiblio calls > >Those calls to C4::Items::GetItemnumbersForBiblio can be replaced with > my @itemnumbers = Koha::Items->search({ biblionumber => $biblionumber})->get_column("itemnumber") > >Test plan: >- Use the GetAvailability service of ILS-DI >- Try to place a hold on an item that is available and another one >- Use the batch record deletion tool to remove record with and without items. >--- > C4/ILSDI/Services.pm | 8 +++++--- > C4/Reserves.pm | 8 ++++---- > C4/SIP/ILS/Patron.pm | 1 - > cataloguing/additem.pl | 4 ++-- > tools/batch_delete_records.pl | 5 +++-- > 5 files changed, 14 insertions(+), 12 deletions(-) > >diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm >index 5534d3ccbc..607c481401 100644 >--- a/C4/ILSDI/Services.pm >+++ b/C4/ILSDI/Services.pm >@@ -38,6 +38,7 @@ use Koha::DateUtils; > > use Koha::Biblios; > use Koha::Checkouts; >+use Koha::Items; > use Koha::Libraries; > use Koha::Patrons; > >@@ -138,14 +139,15 @@ sub GetAvailability { > } else { > my $status; > my $msg; >- my $items = GetItemnumbersForBiblio($id); >- if ($items) { >+ my $items = Koha::Items->search({ biblionumber => $id }); >+ if ($items->count) { > # Open XML > $out .= " <dlf:record>\n"; > $out .= " <dlf:bibliographic id=\"" .$id. "\" />\n"; > $out .= " <dlf:items>\n"; > # We loop over the items to clean them >- foreach my $itemnumber (@$items) { >+ while ( my $item = $items->next ) { >+ my $itemnumber = $item->itemnumber; > my ( $biblionumber, $status, $msg, $location ) = _availability($itemnumber); > $out .= " <dlf:item id=\"" . $itemnumber . "\">\n"; > $out .= " <dlf:simpleavailability>\n"; >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index ab901c8953..a549c3d751 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -275,16 +275,16 @@ See CanItemBeReserved() for possible return values. > sub CanBookBeReserved{ > my ($borrowernumber, $biblionumber) = @_; > >- my $items = GetItemnumbersForBiblio($biblionumber); >+ my @itemnumbers = Koha::Items->search({ biblionumber => $biblionumber})->get_column("itemnumber"); > #get items linked via host records > my @hostitems = get_hostitemnumbers_of($biblionumber); > if (@hostitems){ >- push (@$items,@hostitems); >+ push (@itemnumbers, @hostitems); > } > > my $canReserve; >- foreach my $item (@$items) { >- $canReserve = CanItemBeReserved( $borrowernumber, $item ); >+ foreach my $itemnumber (@itemnumbers) { >+ $canReserve = CanItemBeReserved( $borrowernumber, $itemnumber ); > return 'OK' if $canReserve eq 'OK'; > } > return $canReserve; >diff --git a/C4/SIP/ILS/Patron.pm b/C4/SIP/ILS/Patron.pm >index cee3bac40b..78c75938ea 100644 >--- a/C4/SIP/ILS/Patron.pm >+++ b/C4/SIP/ILS/Patron.pm >@@ -22,7 +22,6 @@ use C4::Context; > use C4::Koha; > use C4::Members; > use C4::Reserves; >-use C4::Items qw( GetItemnumbersForBiblio); > use C4::Auth qw(checkpw); > > use Koha::Items; >diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl >index d36eb15651..6af351d375 100755 >--- a/cataloguing/additem.pl >+++ b/cataloguing/additem.pl >@@ -652,8 +652,8 @@ if ($op eq "additem") { > #------------------------------------------------------------------------------- > } elsif ($op eq "delallitems") { > #------------------------------------------------------------------------------- >- my $itemnumbers = C4::Items::GetItemnumbersForBiblio( $biblionumber ); >- foreach my $itemnumber ( @$itemnumbers ) { >+ my @itemnumbers = Koha::Items->search({ biblionumber => $biblionumber })->get_column('itemnumber'); >+ foreach my $itemnumber ( @itemnumbers ) { > $error = C4::Items::DelItemCheck( $biblionumber, $itemnumber ); > next if $error == 1; # Means ok > push @errors,$error; >diff --git a/tools/batch_delete_records.pl b/tools/batch_delete_records.pl >index 8804e6292a..c985b3dc64 100755 >--- a/tools/batch_delete_records.pl >+++ b/tools/batch_delete_records.pl >@@ -30,6 +30,7 @@ use C4::Biblio; > > use Koha::Authorities; > use Koha::Biblios; >+use Koha::Items; > > my $input = new CGI; > my $op = $input->param('op') // q|form|; >@@ -83,7 +84,7 @@ if ( $op eq 'form' ) { > $biblio = $biblio->unblessed; > my $record = &GetMarcBiblio({ biblionumber => $record_id }); > $biblio->{subtitle} = GetRecordValue( 'subtitle', $record, GetFrameworkCode( $record_id ) ); >- $biblio->{itemnumbers} = C4::Items::GetItemnumbersForBiblio( $record_id ); >+ $biblio->{itemnumbers} = [Koha::Items->search({ biblionumber => $record_id })->get_column('itemnumber')]; > $biblio->{holds_count} = $holds_count; > $biblio->{issues_count} = C4::Biblio::CountItemsIssued( $record_id ); > push @records, $biblio; >@@ -164,7 +165,7 @@ if ( $op eq 'form' ) { > } > > # Delete items >- my @itemnumbers = @{ C4::Items::GetItemnumbersForBiblio( $biblionumber ) }; >+ my @itemnumbers = Koha::Items->search({ biblionumber => $biblionumber })->get_column('itemnumber'); > ITEMNUMBER: for my $itemnumber ( @itemnumbers ) { > my $error = eval { C4::Items::DelItemCheck( $biblionumber, $itemnumber ) }; > if ( $error != 1 or $@ ) { >-- >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 21201
:
77685
|
77686
|
77964
|
77965
|
78114
|
78115