Bugzilla – Attachment 78114 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.70 KB, created by
Marcel de Rooy
on 2018-08-24 08:29:46 UTC
(
hide
)
Description:
Bug 21201: Replace C4::Items::GetItemnumbersForBiblio calls
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2018-08-24 08:29:46 UTC
Size:
5.70 KB
patch
obsolete
>From fbf7f6e969df6b21fc009d14c703cd638dd16cf9 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 >Content-Type: text/plain; charset=utf-8 > >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. > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > 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 9498a77..807f1d6 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 ab901c8..a549c3d 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 3d9de0d..82ccc75 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 d36eb15..6af351d 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 149b44d..0194c5d 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|; >@@ -84,7 +85,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; >@@ -165,7 +166,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.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 21201
:
77685
|
77686
|
77964
|
77965
| 78114 |
78115