From 6d793c11339fc73c0e396626a42836cbd220851b Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Wed, 19 Feb 2014 12:08:18 +0100 Subject: [PATCH] Bug 11701: Fix C4::Context::Zconn Support other parameters too --- C4/Context.pm | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/C4/Context.pm b/C4/Context.pm index f61bf14..ae82fb6 100644 --- a/C4/Context.pm +++ b/C4/Context.pm @@ -687,14 +687,11 @@ C<$auth> whether this connection has rw access (1) or just r access (0 or NULL) =cut sub Zconn { - my $self=shift; - my $server=shift; - my $async=shift; - my $auth=shift; - my $piggyback=shift; - my $syntax=shift; - if ( defined($context->{"Zconn"}->{$server}->{$async}) && (0 == $context->{"Zconn"}->{$server}->{$async}->errcode()) ) { - return $context->{"Zconn"}->{$server}->{$async}; + my ($self, $server, $async, $auth, $piggyback, $syntax) = @_; + + my $cache_key = join ('::', (map { $_ // '' } @_)); + if ( defined($context->{"Zconn"}->{$cache_key}) && (0 == $context->{"Zconn"}->{$cache_key}->errcode()) ) { + return $context->{"Zconn"}->{$cache_key}; # No connection object or it died. Create one. }else { # release resources if we're closing a connection and making a new one @@ -703,12 +700,12 @@ sub Zconn { # and make a new one, particularly for a batch job. However, at # first glance it does not look like there's a way to easily check # the basic health of a ZOOM::Connection - $context->{"Zconn"}->{$server}->{$async}->destroy() if defined($context->{"Zconn"}->{$server}->{$async}); + $context->{"Zconn"}->{$cache_key}->destroy() if defined($context->{"Zconn"}->{$cache_key}); - $context->{"Zconn"}->{$server}->{$async} = &_new_Zconn($server,$async,$auth,$piggyback,$syntax); - $context->{ Zconn }->{ $server }->{$async}->option( + $context->{"Zconn"}->{$cache_key} = &_new_Zconn($server,$async,$auth,$piggyback,$syntax); + $context->{ Zconn }->{$cache_key}->option( preferredRecordSyntax => C4::Context->preference("marcflavour") ); - return $context->{"Zconn"}->{$server}->{$async}; + return $context->{"Zconn"}->{$cache_key}; } } -- 1.7.10.4