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

(-)a/C4/Context.pm (-4 / +7 lines)
Lines 860-871 possibly C<&set_dbh>. Link Here
860
sub dbh
860
sub dbh
861
{
861
{
862
    my $self = shift;
862
    my $self = shift;
863
    my $params = shift;
863
    my $sth;
864
    my $sth;
864
865
865
    if ( defined $db_driver && $db_driver eq 'mysql' && $context->{"dbh"} ) {
866
    unless ( $params->{new} ) {
866
        return $context->{"dbh"};
867
        if ( defined $db_driver && $db_driver eq 'mysql' && $context->{"dbh"} ) {
867
    } elsif ( defined $db_driver && defined($context->{"dbh"}) && $context->{"dbh"}->ping()) {
868
            return $context->{"dbh"};
868
        return $context->{"dbh"};
869
        } elsif ( defined $db_driver && defined($context->{"dbh"}) && $context->{"dbh"}->ping()) {
870
            return $context->{"dbh"};
871
        }
869
    }
872
    }
870
873
871
    # No database handle or it died . Create one.
874
    # No database handle or it died . Create one.
(-)a/t/db_dependent/Context.t (-5 / +1 lines)
Lines 50-58 ok($config = $koha->{config}, 'Getting $koha->{config} '); Link Here
50
50
51
diag "Testing syspref caching.";
51
diag "Testing syspref caching.";
52
52
53
my $dbh = C4::Context->dbh;
54
$dbh->disconnect;
55
56
my $module = new Test::MockModule('C4::Context');
53
my $module = new Test::MockModule('C4::Context');
57
$module->mock(
54
$module->mock(
58
    '_new_dbh',
55
    '_new_dbh',
Lines 64-70 $module->mock( Link Here
64
);
61
);
65
62
66
my $history;
63
my $history;
67
$dbh = C4::Context->dbh;
64
$dbh = C4::Context->dbh({ new => 1 });
68
65
69
$dbh->{mock_add_resultset} = [ ['value'], ['thing1'] ];
66
$dbh->{mock_add_resultset} = [ ['value'], ['thing1'] ];
70
$dbh->{mock_add_resultset} = [ ['value'], ['thing2'] ];
67
$dbh->{mock_add_resultset} = [ ['value'], ['thing2'] ];
71
- 

Return to bug 10611