Bugzilla – Attachment 84056 Details for
Bug 13937
Add an Elasticsearch-compatible Z39.50/SRU daemon
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13937: Fix issues found in QA
Bug-13937-Fix-issues-found-in-QA.patch (text/plain), 9.19 KB, created by
Ere Maijala
on 2019-01-16 12:10:31 UTC
(
hide
)
Description:
Bug 13937: Fix issues found in QA
Filename:
MIME Type:
Creator:
Ere Maijala
Created:
2019-01-16 12:10:31 UTC
Size:
9.19 KB
patch
obsolete
>From 17f09404a3c6de91fff912ea904556068416e4b8 Mon Sep 17 00:00:00 2001 >From: Ere Maijala <ere.maijala@helsinki.fi> >Date: Wed, 21 Nov 2018 16:20:33 +0200 >Subject: [PATCH] Bug 13937: Fix issues found in QA > >--- > C4/Installer/PerlDependencies.pm | 5 -- > Koha/Z3950Responder.pm | 8 +-- > Koha/Z3950Responder/Session.pm | 9 ++-- > misc/bin/koha-zebra-ctl-oma.sh | 88 ++++++++++++++++++++++++++++++++ > misc/z3950_responder.pl | 9 +++- > t/Koha/Z3950responder.t | 23 ++------- > 6 files changed, 108 insertions(+), 34 deletions(-) > create mode 100755 misc/bin/koha-zebra-ctl-oma.sh > >diff --git a/C4/Installer/PerlDependencies.pm b/C4/Installer/PerlDependencies.pm >index c9b6fefc84..323713aa5b 100644 >--- a/C4/Installer/PerlDependencies.pm >+++ b/C4/Installer/PerlDependencies.pm >@@ -893,11 +893,6 @@ our $PERL_DEPS = { > required => '1', > min_ver => '0.37', > }, >- 'Path::Tiny' => { >- usage => 'core', >- required => 1, >- min_ver => '0.058', >- }, > 'Net::Z3950::SimpleServer' => { > 'usage' => 'Z39.50 responder', > 'required' => '0', >diff --git a/Koha/Z3950Responder.pm b/Koha/Z3950Responder.pm >index cda52ead25..c7a7bf2973 100644 >--- a/Koha/Z3950Responder.pm >+++ b/Koha/Z3950Responder.pm >@@ -32,7 +32,7 @@ use Net::Z3950::SimpleServer; > sub new { > my ( $class, $config ) = @_; > >- my ($item_tag, $itemnumber_subfield) = GetMarcFromKohaField( "items.itemnumber", '' ); >+ my ($item_tag, $itemnumber_subfield) = GetMarcFromKohaField( "items.itemnumber" ); > > # We hardcode the strings for English so SOMETHING will work if the authorized value doesn't exist. > my $status_strings = { >@@ -57,13 +57,13 @@ sub new { > status_strings => $status_strings, > }; > >- # Turn off Yaz's built-in logging (can be turned back on if desired). >- unshift @{ $self->{yaz_options} }, '-v', 'none'; >- > # If requested, turn on debugging. > if ( $self->{debug} ) { > # Turn on single-process mode. > unshift @{ $self->{yaz_options} }, '-S'; >+ } else { >+ # Turn off Yaz's built-in logging apart from fatal errors (can be turned back on if desired). >+ unshift @{ $self->{yaz_options} }, '-v', 'none,fatal'; > } > > $self->{server} = Net::Z3950::SimpleServer->new( >diff --git a/Koha/Z3950Responder/Session.pm b/Koha/Z3950Responder/Session.pm >index 209a96d858..338056bb15 100644 >--- a/Koha/Z3950Responder/Session.pm >+++ b/Koha/Z3950Responder/Session.pm >@@ -80,6 +80,7 @@ sub _log_error { > > sub _set_error { > my ( $self, $args, $code, $msg ) = @_; >+ > ( $args->{ERR_CODE}, $args->{ERR_STR} ) = ( $code, $msg ); > > $self->_log_error(" returning error $code: $msg"); >@@ -140,8 +141,8 @@ sub _check_fetch { > return 0; > } > >- if ( $offset + $num_records > $resultset->{hits} ) { >- $self->_set_error( $args, ERR_PRESENT_OUT_OF_RANGE, 'Fetch request out of range' ); >+ if ( $offset < 0 || $offset + $num_records > $resultset->{hits} ) { >+ $self->_set_error( $args, ERR_PRESENT_OUT_OF_RANGE, 'Present request out of range' ); > return 0; > } > >@@ -155,7 +156,7 @@ sub _fetch_record { > > eval { > if ( !$resultset->{results}->record_immediate( $index ) ) { >- my $start = int( $index / $num_to_prefetch ) * $num_to_prefetch; >+ my $start = $num_to_prefetch ? int( $index / $num_to_prefetch ) * $num_to_prefetch : $index; > > if ( $start + $num_to_prefetch >= $resultset->{results}->size() ) { > $num_to_prefetch = $resultset->{results}->size() - $start; >@@ -184,7 +185,7 @@ sub search_handler { > my $database = $args->{DATABASES}->[0]; > > if ( $database !~ /^(biblios|authorities)$/ ) { >- $self->_set_error( ERR_DB_DOES_NOT_EXIST, 'No such database' ); >+ $self->_set_error( $args, ERR_DB_DOES_NOT_EXIST, 'No such database' ); > return; > } > >diff --git a/misc/bin/koha-zebra-ctl-oma.sh b/misc/bin/koha-zebra-ctl-oma.sh >new file mode 100755 >index 0000000000..d5e2ffa69d >--- /dev/null >+++ b/misc/bin/koha-zebra-ctl-oma.sh >@@ -0,0 +1,88 @@ >+#!/bin/bash >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+### BEGIN INIT INFO >+# Provides: koha-zebra-daemon >+# Required-Start: $syslog $remote_fs >+# Required-Stop: $syslog $remote_fs >+# Default-Start: 2 3 4 5 >+# Default-Stop: 0 1 6 >+# Short-Description: Zebra server daemon for Koha indexing >+### END INIT INFO >+ >+USER=ere >+GROUP=users >+DBNAME=koha3 >+NAME=koha-zebra-ctl.koha3 >+LOGDIR=/home/ere/koha-dev/var/log >+ERRLOG=$LOGDIR/koha-zebradaemon.err >+STDOUT=$LOGDIR/koha-zebradaemon.log >+OUTPUT=$LOGDIR/koha-zebradaemon-output.log >+KOHA_CONF=/home/ere/koha-dev/etc/koha-conf.xml >+RUNDIR=/home/ere/koha-dev/var/run >+LOCKDIR=/home/ere/koha-dev/var/lock >+# you may need to change this depending on where zebrasrv is installed >+ZEBRASRV=/usr/bin/zebrasrv >+ZEBRAOPTIONS="-v none,fatal,warn" >+ >+test -f $ZEBRASRV || exit 0 >+ >+OTHERUSER='' >+if [[ $EUID -eq 0 ]]; then >+ OTHERUSER="--user=$USER.$GROUP" >+fi >+ >+case "$1" in >+ start) >+ echo "Starting Zebra Server" >+ >+ # create run and lock directories if needed; >+ # /var/run and /var/lock are completely cleared at boot >+ # on some platforms >+ if [[ ! -d $RUNDIR ]]; then >+ umask 022 >+ mkdir -p $RUNDIR >+ if [[ $EUID -eq 0 ]]; then >+ chown $USER:$GROUP $RUNDIR >+ fi >+ fi >+ if [[ ! -d $LOCKDIR ]]; then >+ umask 022 >+ mkdir -p $LOCKDIR >+ mkdir -p $LOCKDIR/biblios >+ mkdir -p $LOCKDIR/authorities >+ mkdir -p $LOCKDIR/rebuild >+ if [[ $EUID -eq 0 ]]; then >+ chown -R $USER:$GROUP $LOCKDIR >+ fi >+ fi >+ >+ daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 $OTHERUSER -- $ZEBRASRV $ZEBRAOPTIONS -f $KOHA_CONF >+ ;; >+ stop) >+ echo "Stopping Zebra Server" >+ daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 $OTHERUSER --stop -- $ZEBRASRV -f $KOHA_CONF >+ ;; >+ restart) >+ echo "Restarting the Zebra Server" >+ daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 $OTHERUSER --restart -- $ZEBRASRV -f $KOHA_CONF >+ ;; >+ *) >+ echo "Usage: /etc/init.d/$NAME {start|stop|restart}" >+ exit 1 >+ ;; >+esac >diff --git a/misc/z3950_responder.pl b/misc/z3950_responder.pl >index 2e63177d22..729934338d 100755 >--- a/misc/z3950_responder.pl >+++ b/misc/z3950_responder.pl >@@ -36,6 +36,9 @@ use Koha::Z3950Responder; > > =head1 OPTIONS > >+See https://software.indexdata.com/yaz/doc/server.invocation.html for more information about YAZ options >+not described below. >+ > =over 8 > > =item B<--help> >@@ -102,7 +105,6 @@ my @yaz_options; > > sub add_yaz_option { > my ( $opt_name, $opt_value ) = @_; >- warn "name: $opt_name and value: $opt_value"; > > push @yaz_options, "-$opt_name", "$opt_value"; > } >@@ -145,6 +147,11 @@ GetOptions( > pod2usage(1) if $help; > pod2usage( -verbose => 2 ) if $man; > >+if (!@ARGV || $ARGV[-1] =~ /^-/) { >+ # No bind address specified. Use @:2100 by default. >+ push(@ARGV, '@:2100'); >+} >+ > # Create and start the server. > > die "This tool only works with Zebra" if C4::Context->preference('SearchEngine') ne 'Zebra'; >diff --git a/t/Koha/Z3950responder.t b/t/Koha/Z3950responder.t >index 3d74e5df8f..7f2219783b 100644 >--- a/t/Koha/Z3950responder.t >+++ b/t/Koha/Z3950responder.t >@@ -1,7 +1,7 @@ > #!/usr/bin/perl > > use Modern::Perl; >-use Test::More tests => 8; >+use Test::More tests => 2; > > BEGIN { > use_ok('Koha::Z3950Responder'); >@@ -9,23 +9,6 @@ BEGIN { > > my $zR = Koha::Z3950Responder->new({}); > >-my $args={ PEER_NAME => 'PEER'}; >+my $args = { PEER_NAME => 'PEER' }; > $zR->init_handler($args); >-is ( $args->{IMP_NAME}, 'Koha',"Server returns basic info"); >-$args->{DATABASES} = ['biblios']; >-$args->{QUERY} = 'biblios'; >-$args->{SETNAME} = 'biblios'; >-$args->{START} = 0; >-$args->{OFFSET} = 0; >-$args->{NUMBER} = 42; >-$zR->search_handler( $args ); >-is ( $args->{ERR_CODE}, 2, "We didn't start server , should fail"); >-is ( $args->{ERR_STR}, 'Cannot connect to upstream server', "We didn't start server, should fail because it cannot connect"); >-$zR->present_handler( $args ); >-is ( $args->{ERR_CODE}, 30, "There is no handler as we aren't connected"); >-is ( $args->{ERR_STR}, 'No such resultset', "We don't have a handler, should fail because we don't"); >-my $arg_check = ( $args ); >-$zR->fetch_handler( $args ); >-is_deeply( $args, $arg_check, "nothing should change"); >-$zR->close_handler( $args ); >-is_deeply( $args, $arg_check, "nothing should change"); >+is ( $args->{IMP_NAME}, 'Koha', 'Server returns basic info' ); >-- >2.17.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 13937
:
46369
|
47417
|
47418
|
47419
|
53503
|
58122
|
58125
|
58126
|
59443
|
59444
|
60735
|
60736
|
60737
|
60738
|
66943
|
66944
|
66945
|
66946
|
69139
|
82562
|
82563
|
82564
|
82565
|
82566
|
82567
|
82589
|
82590
|
82591
|
82592
|
82593
|
82594
|
82595
|
82660
|
82661
|
82662
|
82663
|
82664
|
82665
|
82666
|
82667
|
83780
|
83781
|
83782
|
83783
|
83784
|
83785
|
83786
|
83787
|
83788
|
83789
|
83951
|
83952
|
83953
|
83954
|
83955
|
83956
|
83957
|
83958
|
83959
|
84050
|
84051
|
84052
|
84053
|
84054
|
84055
|
84056
|
84057
|
84058
|
84059
|
84062
|
84063
|
84064
|
84065
|
84066
|
84067
|
84068
|
84069
|
84072
|
84073
|
85112
|
86353
|
86354
|
86355
|
86356
|
86357
|
86358
|
86359
|
86360
|
86361
|
86362
|
86363
|
86364
|
88907
|
88908
|
88909
|
88910
|
88911
|
88912
|
88913
|
88914
|
88915
|
88916
|
88917
|
88918
|
91728
|
91729
|
91730
|
91731
|
91732
|
91733
|
91734
|
91735
|
91736
|
91737
|
91738
|
91739
|
91740
|
93913
|
94097
|
94109
|
94110
|
94209
|
94616
|
94647