@@ -, +, @@ ping $dbh = C4::Context->dbh; my $dbh = C4::Context->dbh; --- C4/Context.pm | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) --- a/C4/Context.pm +++ a/C4/Context.pm @@ -789,16 +789,14 @@ 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_schme - my $db_driver; + ## correct name for db_schme if ($context->config("db_scheme")){ $db_driver=db_scheme2dbi($context->config("db_scheme")); - }else{ - $db_driver="mysql"; } my $db_name = $context->config("database"); @@ -824,6 +822,10 @@ sub _new_dbh $dbh->{RaiseError} = 0; } + if ( $db_driver eq 'mysql' ) { + $dbh->{mysql_auto_reconnect} = 1; + } + my $tz = $ENV{TZ}; if ( $db_driver eq 'mysql' ) { # Koha 3.0 is utf-8, so force utf8 communication between mySQL and koha, whatever the mysql default config. @@ -860,8 +862,10 @@ sub dbh my $self = shift; my $sth; - if (defined($context->{"dbh"}) && $context->{"dbh"}->ping()) { - return $context->{"dbh"}; + if ( defined $db_driver && $db_driver eq 'mysql' && $context->{"dbh"} ) { + return $context->{"dbh"}; + } elsif ( defined $db_driver && defined($context->{"dbh"}) && $context->{"dbh"}->ping()) { + return $context->{"dbh"}; } # No database handle or it died . Create one. --