Bug 7847: OPAC search dies with Plack
authorJared Camins-Esakov <jcamins@cpbibliography.com>
Mon, 28 May 2012 23:27:45 +0000 (19:27 -0400)
committerPaul Poulain <paul.poulain@biblibre.com>
Tue, 5 Jun 2012 13:46:20 +0000 (15:46 +0200)
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.

Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
C4/Items.pm
C4/Search.pm

index a6d5a22..9f4b9b3 100644 (file)
@@ -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");
index 3794676..7d18b73 100644 (file)
@@ -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';