From 7d39b3c72ea2422b09e3411bef974d87aecdabf9 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Mon, 10 Mar 2014 22:48:03 +0000 Subject: [PATCH] Bug 10611: (follow-up) cache DBMS driver code in context object Rather than use a package-level variable, use an object-level one. Signed-off-by: Galen Charlton --- C4/Context.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/C4/Context.pm b/C4/Context.pm index c3b568581a..5a76137556 100644 --- a/C4/Context.pm +++ b/C4/Context.pm @@ -293,7 +293,7 @@ sub memcached { } } -=head2 db_schema2dbi +=head2 db_scheme2dbi my $dbd_driver_name = C4::Context::db_schema2dbi($scheme); @@ -401,6 +401,7 @@ sub new { $self->{tz} = undef; # local timezone object bless $self, $class; + $self->{db_driver} = db_scheme2dbi($self->config('db_scheme')); # cache database driver return $self; } @@ -793,13 +794,12 @@ sub _new_Zconn { # Internal helper function (not a method!). This creates a new # database connection from the data given in the current context, and # returns it. -our $db_driver = 'mysql'; sub _new_dbh { ## $context ## correct name for db_scheme - my $db_driver = db_scheme2dbi($context->config("db_scheme")); + my $db_driver = $context->{db_driver}; my $db_name = $context->config("database"); my $db_host = $context->config("hostname"); @@ -866,9 +866,9 @@ sub dbh my $sth; unless ( $params->{new} ) { - if ( defined $db_driver && $db_driver eq 'mysql' && $context->{"dbh"} ) { + if ( defined($context->{db_driver}) && $context->{db_driver} eq 'mysql' && $context->{"dbh"} ) { return $context->{"dbh"}; - } elsif ( defined $db_driver && defined($context->{"dbh"}) && $context->{"dbh"}->ping()) { + } elsif ( defined($context->{"dbh"}) && $context->{"dbh"}->ping() ) { return $context->{"dbh"}; } } -- 2.39.5