From c973bad6eaaea3ec5255ebe684eab2881e2a580d Mon Sep 17 00:00:00 2001 From: Jared Camins-Esakov Date: Mon, 28 May 2012 19:27:45 -0400 Subject: [PATCH] Bug 7847: OPAC search dies with Plack Content-Type: text/plain; charset="UTF-8" Due to a dependency cycle between C4::Search and C4::Items, searches in the OPAC die spectacularly under Plack. This counter-patch extends dpavlin's solution and replaces use with require for C4::Search in C4::Items and for C4::Items in C4::Search. --- C4/Items.pm | 2 +- C4/Search.pm | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/C4/Items.pm b/C4/Items.pm index a6d5a22..9f4b9b3 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -30,7 +30,6 @@ use MARC::Record; use C4::ClassSource; use C4::Log; use List::MoreUtils qw/any/; -use C4::Search; use Data::Dumper; # used as part of logging item record changes, not just for # debugging; so please don't remove this @@ -2481,6 +2480,7 @@ counts Usage of itemnumber in Analytical bibliorecords. sub GetAnalyticsCount { my ($itemnumber) = @_; + require C4::Search; if (C4::Context->preference('NoZebra')) { # Read the index Koha-Auth-Number for this authid and count the lines my $result = C4::Search::NZanalyse("hi=$itemnumber"); diff --git a/C4/Search.pm b/C4/Search.pm index 3794676..7d18b73 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -30,7 +30,6 @@ use C4::XSLT; use C4::Branch; use C4::Reserves; # CheckReserves use C4::Debug; -use C4::Items; use C4::Charset; use YAML; use URI::Escape; @@ -1418,6 +1417,8 @@ sub searchResults { my $dbh = C4::Context->dbh; my @newresults; + require C4::Items; + $search_context = 'opac' if !$search_context || $search_context ne 'intranet'; my ($is_opac, $hidelostitems); if ($search_context eq 'opac') { @@ -1631,9 +1632,9 @@ sub searchResults { # Hidden items if ($is_opac) { - my @hi = GetHiddenItemnumbers($item); - $item->{'hideatopac'} = @hi; - push @hiddenitems, @hi; + my @hi = C4::Items::GetHiddenItemnumbers($item); + $item->{'hideatopac'} = @hi; + push @hiddenitems, @hi; } my $hbranch = C4::Context->preference('HomeOrHoldingBranch') eq 'homebranch' ? 'homebranch' : 'holdingbranch'; -- 1.7.2.5