View | Details | Raw Unified | Return to bug 10611
Collapse All | Expand All

(-)a/C4/Context.pm (-6 / +13 lines)
Lines 788-803 sub _new_Zconn { Link Here
788
# Internal helper function (not a method!). This creates a new
788
# Internal helper function (not a method!). This creates a new
789
# database connection from the data given in the current context, and
789
# database connection from the data given in the current context, and
790
# returns it.
790
# returns it.
791
our $db_driver = 'mysql';
791
sub _new_dbh
792
sub _new_dbh
792
{
793
{
793
794
794
    ## $context
795
    ## $context
795
    ## correct name for db_schme        
796
    ## correct name for db_schme
796
    my $db_driver;
797
    if ($context->config("db_scheme")){
797
    if ($context->config("db_scheme")){
798
        $db_driver=db_scheme2dbi($context->config("db_scheme"));
798
        $db_driver=db_scheme2dbi($context->config("db_scheme"));
799
    }else{
800
        $db_driver="mysql";
801
    }
799
    }
802
800
803
    my $db_name   = $context->config("database");
801
    my $db_name   = $context->config("database");
Lines 823-828 sub _new_dbh Link Here
823
        $dbh->{RaiseError} = 0;
821
        $dbh->{RaiseError} = 0;
824
    }
822
    }
825
823
824
    if ( $db_driver eq 'mysql' ) {
825
        $dbh->{mysql_auto_reconnect} = 1;
826
    }
827
826
	my $tz = $ENV{TZ};
828
	my $tz = $ENV{TZ};
827
    if ( $db_driver eq 'mysql' ) { 
829
    if ( $db_driver eq 'mysql' ) { 
828
        # Koha 3.0 is utf-8, so force utf8 communication between mySQL and koha, whatever the mysql default config.
830
        # Koha 3.0 is utf-8, so force utf8 communication between mySQL and koha, whatever the mysql default config.
Lines 857-866 possibly C<&set_dbh>. Link Here
857
sub dbh
859
sub dbh
858
{
860
{
859
    my $self = shift;
861
    my $self = shift;
862
    my $params = shift;
860
    my $sth;
863
    my $sth;
861
864
862
    if (defined($context->{"dbh"}) && $context->{"dbh"}->ping()) {
865
    unless ( $params->{new} ) {
863
	return $context->{"dbh"};
866
        if ( defined $db_driver && $db_driver eq 'mysql' && $context->{"dbh"} ) {
867
            return $context->{"dbh"};
868
        } elsif ( defined $db_driver && defined($context->{"dbh"}) && $context->{"dbh"}->ping()) {
869
            return $context->{"dbh"};
870
        }
864
    }
871
    }
865
872
866
    # No database handle or it died . Create one.
873
    # No database handle or it died . Create one.
(-)a/installer/install.pl (-2 lines)
Lines 382-389 elsif ( $step && $step == 3 ) { Link Here
382
                                );
382
                                );
383
            }
383
            }
384
        }
384
        }
385
386
        $dbh->disconnect;
387
    }
385
    }
388
}
386
}
389
else {
387
else {
(-)a/misc/cronjobs/j2a.pl (-1 lines)
Lines 234-237 if ( not $noaction) { Link Here
234
	}
234
	}
235
	$sth->finish(  );
235
	$sth->finish(  );
236
}
236
}
237
$dbh->disconnect();
(-)a/sms/sms_listen.pl (-1 lines)
Lines 108-114 foreach my $user(@phones){ Link Here
108
	}
108
	}
109
	print $reply;
109
	print $reply;
110
}
110
}
111
$dbh->disconnect;
112
111
113
sub send_message {
112
sub send_message {
114
	my ($mes,$message,$smsid)=@_;
113
	my ($mes,$message,$smsid)=@_;
(-)a/t/db_dependent/Context.t (-5 / +1 lines)
Lines 44-52 ok($config = $koha->{config}, 'Getting $koha->{config} '); Link Here
44
44
45
diag "Testing syspref caching.";
45
diag "Testing syspref caching.";
46
46
47
my $dbh = C4::Context->dbh;
48
$dbh->disconnect;
49
50
my $module = new Test::MockModule('C4::Context');
47
my $module = new Test::MockModule('C4::Context');
51
$module->mock(
48
$module->mock(
52
    '_new_dbh',
49
    '_new_dbh',
Lines 58-64 $module->mock( Link Here
58
);
55
);
59
56
60
my $history;
57
my $history;
61
$dbh = C4::Context->dbh;
58
$dbh = C4::Context->dbh({ new => 1 });
62
59
63
$dbh->{mock_add_resultset} = [ ['value'], ['thing1'] ];
60
$dbh->{mock_add_resultset} = [ ['value'], ['thing1'] ];
64
$dbh->{mock_add_resultset} = [ ['value'], ['thing2'] ];
61
$dbh->{mock_add_resultset} = [ ['value'], ['thing2'] ];
65
- 

Return to bug 10611