View | Details | Raw Unified | Return to bug 14962
Collapse All | Expand All

(-)a/C4/Search.pm (-8 / +17 lines)
Lines 1699-1713 sub searchResults { Link Here
1699
    my $itemtypes = Koha::ItemTypes->search_with_localization;
1699
    my $itemtypes = Koha::ItemTypes->search_with_localization;
1700
    my %itemtypes = map { $_->{itemtype} => $_ } @{ $itemtypes->unblessed };
1700
    my %itemtypes = map { $_->{itemtype} => $_ } @{ $itemtypes->unblessed };
1701
1701
1702
    # Cache for display lookups to avoid repeated queries
1702
    # Caches shared across all display-aware helper closures
1703
    my $display_cache = {};
1703
    my $display_cache  = {};
1704
    my $item_obj_cache = {};
1705
1706
    # Returns a Koha::Item object for the given itemnumber, cached per result set
1707
    my $get_item_obj = sub {
1708
        my ($itemnumber) = @_;
1709
        unless ( exists $item_obj_cache->{$itemnumber} ) {
1710
            $item_obj_cache->{$itemnumber} = Koha::Items->find($itemnumber);
1711
        }
1712
        return $item_obj_cache->{$itemnumber};
1713
    };
1704
1714
1705
    # Helper function to get effective location for search results
1715
    # Helper function to get effective location for search results
1706
    my $get_effective_collection_code = sub {
1716
    my $get_effective_collection_code = sub {
1707
        my ($item) = @_;
1717
        my ($item) = @_;
1708
        return $collections->{ $item->{ccode} } unless C4::Context->preference('UseDisplayModule');
1718
        return $collections->{ $item->{ccode} } unless C4::Context->preference('UseDisplayModule');
1709
1719
1710
        my $item_obj = Koha::Items->find( $item->{itemnumber} );
1720
        my $item_obj = $get_item_obj->( $item->{itemnumber} );
1711
        return $collections->{ $item->{ccode} } unless $item_obj;
1721
        return $collections->{ $item->{ccode} } unless $item_obj;
1712
1722
1713
        my $effective_collection_code = $item_obj->effective_collection_code;
1723
        my $effective_collection_code = $item_obj->effective_collection_code;
Lines 1732-1738 sub searchResults { Link Here
1732
        my ($item) = @_;
1742
        my ($item) = @_;
1733
        return $itemtypes{ $item->{itype} }{translated_description} unless C4::Context->preference('UseDisplayModule');
1743
        return $itemtypes{ $item->{itype} }{translated_description} unless C4::Context->preference('UseDisplayModule');
1734
1744
1735
        my $item_obj = Koha::Items->find( $item->{itemnumber} );
1745
        my $item_obj = $get_item_obj->( $item->{itemnumber} );
1736
        return $itemtypes{ $item->{itype} }{translated_description} unless $item_obj;
1746
        return $itemtypes{ $item->{itype} }{translated_description} unless $item_obj;
1737
1747
1738
        my $effective_itemtype = $item_obj->effective_itemtype;
1748
        my $effective_itemtype = $item_obj->effective_itemtype;
Lines 1757-1763 sub searchResults { Link Here
1757
        my ($item) = @_;
1767
        my ($item) = @_;
1758
        return $shelflocations->{ $item->{location} } unless C4::Context->preference('UseDisplayModule');
1768
        return $shelflocations->{ $item->{location} } unless C4::Context->preference('UseDisplayModule');
1759
1769
1760
        my $item_obj = Koha::Items->find( $item->{itemnumber} );
1770
        my $item_obj = $get_item_obj->( $item->{itemnumber} );
1761
        return $shelflocations->{ $item->{location} } unless $item_obj;
1771
        return $shelflocations->{ $item->{location} } unless $item_obj;
1762
1772
1763
        my $effective_loc = $shelflocations->{ $item_obj->effective_location };
1773
        my $effective_loc = $shelflocations->{ $item_obj->effective_location };
Lines 1780-1786 sub searchResults { Link Here
1780
        my ($item) = @_;
1790
        my ($item) = @_;
1781
        return $item->{homebranch} unless C4::Context->preference('UseDisplayModule');
1791
        return $item->{homebranch} unless C4::Context->preference('UseDisplayModule');
1782
1792
1783
        my $item_obj = Koha::Items->find( $item->{itemnumber} );
1793
        my $item_obj = $get_item_obj->( $item->{itemnumber} );
1784
        return $item->{homebranch} unless $item_obj;
1794
        return $item->{homebranch} unless $item_obj;
1785
1795
1786
        my $effective_homebranch = $item_obj->effective_homebranch;
1796
        my $effective_homebranch = $item_obj->effective_homebranch;
Lines 1805-1811 sub searchResults { Link Here
1805
        my ($item) = @_;
1815
        my ($item) = @_;
1806
        return $item->{holdingbranch} unless C4::Context->preference('UseDisplayModule');
1816
        return $item->{holdingbranch} unless C4::Context->preference('UseDisplayModule');
1807
1817
1808
        my $item_obj = Koha::Items->find( $item->{itemnumber} );
1818
        my $item_obj = $get_item_obj->( $item->{itemnumber} );
1809
        return $item->{holdingbranch} unless $item_obj;
1819
        return $item->{holdingbranch} unless $item_obj;
1810
1820
1811
        my $effective_holdingbranch = $item_obj->effective_holdingbranch;
1821
        my $effective_holdingbranch = $item_obj->effective_holdingbranch;
1812
- 

Return to bug 14962