@@ -, +, @@ $dbh = C4::Context->dbh; --- C4/Context.pm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) --- a/C4/Context.pm +++ a/C4/Context.pm @@ -782,12 +782,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; sub _new_dbh { ## $context ## correct name for db_schme - my $db_driver; if ($context->config("db_scheme")){ $db_driver=db_scheme2dbi($context->config("db_scheme")); }else{ @@ -817,6 +817,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. @@ -853,8 +857,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. --