From 44f7c1fa594f68d1cadacc9d47c1e64819fdbb47 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Fri, 24 Jun 2016 11:29:02 -0400 Subject: [PATCH] Bug 16746: Proposed start of counter-patch This is the beginning of a counter patch. Feel free to apply it and test it, Juan Romay Sieira. However, please expand the test plan to be more detailed: -- type X into field Y -- click button Z -- click downdrop W -- select item V -- enter 'text' into text box labelled A "Add a new authority that exists in your authority server, Koha will now find none." is not detailed enough for a person unfamiliar with the interface. Feel free to apply 16809 first. :) --- Koha/SearchEngine/Zebra/Search.pm | 45 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/Koha/SearchEngine/Zebra/Search.pm b/Koha/SearchEngine/Zebra/Search.pm index cb69e22..2f47822 100644 --- a/Koha/SearchEngine/Zebra/Search.pm +++ b/Koha/SearchEngine/Zebra/Search.pm @@ -21,13 +21,48 @@ use Modern::Perl; use base qw(Class::Accessor); +# Added index accessor, because base isn't Koha::SearchEngine +# Because of nasty nested loopy dependencies that would +# break things if it was changed right now. +__PACKAGE__->mk_ro_accessors(qw( index )); + use C4::Search; # :( use C4::AuthoritiesMarc; +use Carp; =head1 NAME Koha::SearchEngine::Zebra::Search - Search implementation for Zebra +=head1 ACCESSORS + +=over 4 + +=item index + +The name of the index to use, generally 'biblios' or 'authorities'. +It is provided as a parameter when this is instantiated. + + my $index = 'authorities'; # could be 'biblios' + my $searcher = + Koha::SearchEngine::Zebra::Search->new( { index => $index } ); + +=back + +=cut + +sub new { + my @parameters = @_; + my $class = shift @parameters; + my $self = $class->SUPER::new(@parameters); + + # Check for a valid index + if ( !defined $self->index ) { + croak('No index name provided'); + } + return $self; +} + =head1 METHODS =head2 search @@ -72,8 +107,14 @@ This passes straight through to C4::Search::SimpleSearch. sub simple_search_compat { - shift; - return C4::Search::SimpleSearch(@_); + my @parameters = @_; + my $self = shift @parameters; + + # default is ['biblioserver'], so just fix authorities. + if ( $self->index eq 'authorities' ) { + push @parameters, ['authorityserver']; + } + return C4::Search::SimpleSearch(@parameters); } =head2 search_auth_compat -- 2.1.4