Commit 86a245f0 authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 530270: Whining fails if mail queueing is enabled - Patch by Fré©ric…

Bug 530270: Whining fails if mail queueing is enabled - Patch by Fré©ric Buclin <LpSolit@gmail.com> r=mkanat a=LpSolit
parent 0dda0671
...@@ -386,12 +386,17 @@ sub job_queue { ...@@ -386,12 +386,17 @@ sub job_queue {
sub dbh { sub dbh {
my $class = shift; my $class = shift;
# If we're not connected, then we must want the main db # If we're not connected, then we must want the main db
$class->request_cache->{dbh} ||= $class->request_cache->{dbh_main} $class->request_cache->{dbh} ||= $class->dbh_main;
= Bugzilla::DB::connect_main();
return $class->request_cache->{dbh}; return $class->request_cache->{dbh};
} }
sub dbh_main {
my $class = shift;
$class->request_cache->{dbh_main} ||= Bugzilla::DB::connect_main();
return $class->request_cache->{dbh_main};
}
sub languages { sub languages {
my $class = shift; my $class = shift;
return $class->request_cache->{languages} return $class->request_cache->{languages}
...@@ -487,7 +492,7 @@ sub switch_to_shadow_db { ...@@ -487,7 +492,7 @@ sub switch_to_shadow_db {
if ($class->params->{'shadowdb'}) { if ($class->params->{'shadowdb'}) {
$class->request_cache->{dbh_shadow} = Bugzilla::DB::connect_shadow(); $class->request_cache->{dbh_shadow} = Bugzilla::DB::connect_shadow();
} else { } else {
$class->request_cache->{dbh_shadow} = request_cache()->{dbh_main}; $class->request_cache->{dbh_shadow} = $class->dbh_main;
} }
} }
...@@ -501,11 +506,8 @@ sub switch_to_shadow_db { ...@@ -501,11 +506,8 @@ sub switch_to_shadow_db {
sub switch_to_main_db { sub switch_to_main_db {
my $class = shift; my $class = shift;
$class->request_cache->{dbh} = $class->request_cache->{dbh_main}; $class->request_cache->{dbh} = $class->dbh_main;
# We have to return $class->dbh instead of {dbh} as return $class->dbh_main;
# {dbh_main} may be undefined if no connection to the main DB
# has been established yet.
return $class->dbh;
} }
sub get_fields { sub get_fields {
...@@ -796,6 +798,10 @@ used to automatically answer or skip prompts. ...@@ -796,6 +798,10 @@ used to automatically answer or skip prompts.
The current database handle. See L<DBI>. The current database handle. See L<DBI>.
=item C<dbh_main>
The main database handle. See L<DBI>.
=item C<languages> =item C<languages>
Currently installed languages. Currently installed languages.
......
...@@ -43,9 +43,11 @@ sub new { ...@@ -43,9 +43,11 @@ sub new {
} }
my $lc = Bugzilla->localconfig; my $lc = Bugzilla->localconfig;
# We need to use the main DB as TheSchwartz module is going
# to write to it.
my $self = $class->SUPER::new( my $self = $class->SUPER::new(
databases => [{ databases => [{
dsn => Bugzilla->dbh->{private_bz_dsn}, dsn => Bugzilla->dbh_main->{private_bz_dsn},
user => $lc->{db_user}, user => $lc->{db_user},
pass => $lc->{db_pass}, pass => $lc->{db_pass},
prefix => 'ts_', prefix => 'ts_',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment