Bug 19940: Koha::Biblio - Remove GetBiblioItemInfosOf
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 9 Jan 2018 16:58:53 +0000 (13:58 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 23 Mar 2018 14:45:38 +0000 (11:45 -0300)
This subroutine is only used once and can be replaced easily with a
Koha::Biblioitems->search call

Test plan:
Test this on top of bug 19941 and confirm that the correct item types
are displayed

Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

C4/Biblio.pm
reserve/request.pl

index 4eed6b7..89bb4f8 100644 (file)
@@ -68,7 +68,6 @@ BEGIN {
       GetBiblioData
       GetMarcBiblio
       GetBiblioItemData
-      GetBiblioItemInfosOf
 
       &GetRecordValue
 
@@ -885,28 +884,6 @@ sub GetISBDView {
     return $res;
 }
 
-=head2 GetBiblioItemInfosOf
-
-  GetBiblioItemInfosOf(@biblioitemnumbers);
-
-=cut
-
-sub GetBiblioItemInfosOf {
-    my @biblioitemnumbers = @_;
-
-    my $biblioitemnumber_values = @biblioitemnumbers ? join( ',', @biblioitemnumbers ) : "''";
-
-    my $dbh = C4::Context->dbh;
-    my $query = "
-        SELECT biblioitemnumber,
-            publicationyear,
-            itemtype
-        FROM biblioitems
-        WHERE biblioitemnumber IN ($biblioitemnumber_values)
-    ";
-    return $dbh->selectall_hashref($query, 'biblioitemnumber');
-}
-
 =head1 FUNCTIONS FOR HANDLING MARC MANAGEMENT
 
 =head2 IsMarcStructureInternal
index d94a8ab..f92b2ab 100755 (executable)
@@ -316,8 +316,16 @@ foreach my $biblionumber (@biblionumbers) {
     ## Should be same as biblionumber
     my @biblioitemnumbers = keys %itemnumbers_of_biblioitem;
 
-    ## Hash of biblioitemnumber to 'biblioitem' table records
-    my $biblioiteminfos_of  = GetBiblioItemInfosOf(@biblioitemnumbers);
+    my $biblioiteminfos_of = {
+        map {
+            my $biblioitem = $_;
+            ( $biblioitem->{biblioitemnumber} => $biblioitem )
+          } @{ Koha::Biblioitems->search(
+                { biblioitemnumber => { -in => \@biblioitemnumbers } },
+                { select => ['biblioitemnumber', 'publicationyear', 'itemtype']}
+            )->unblessed
+          }
+    };
 
     my $frameworkcode = GetFrameworkCode( $biblionumber );
     my @notforloan_avs = Koha::AuthorisedValues->search_by_koha_field({ kohafield => 'items.notforloan', frameworkcode => $frameworkcode });