]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 530270: Whining fails if mail queueing is enabled - Patch by Frédéric Buclin...
authorlpsolit%gmail.com <>
Sun, 22 Nov 2009 22:24:07 +0000 (22:24 +0000)
committerlpsolit%gmail.com <>
Sun, 22 Nov 2009 22:24:07 +0000 (22:24 +0000)
Bugzilla.pm
Bugzilla/JobQueue.pm

index 3c547b9800e132e9bc163ad3c7e1a3e0a8d2ba6b..b85186e6ef3fd35e7e3ad32c63c778b9674d13dc 100644 (file)
@@ -386,12 +386,17 @@ sub job_queue {
 sub dbh {
     my $class = shift;
     # If we're not connected, then we must want the main db
-    $class->request_cache->{dbh} ||= $class->request_cache->{dbh_main} 
-        = Bugzilla::DB::connect_main();
+    $class->request_cache->{dbh} ||= $class->dbh_main;
 
     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 {
     my $class = shift;
     return $class->request_cache->{languages}
@@ -487,7 +492,7 @@ sub switch_to_shadow_db {
         if ($class->params->{'shadowdb'}) {
             $class->request_cache->{dbh_shadow} = Bugzilla::DB::connect_shadow();
         } 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 {
 sub switch_to_main_db {
     my $class = shift;
 
-    $class->request_cache->{dbh} = $class->request_cache->{dbh_main};
-    # We have to return $class->dbh instead of {dbh} as
-    # {dbh_main} may be undefined if no connection to the main DB
-    # has been established yet.
-    return $class->dbh;
+    $class->request_cache->{dbh} = $class->dbh_main;
+    return $class->dbh_main;
 }
 
 sub get_fields {
@@ -796,6 +798,10 @@ used to automatically answer or skip prompts.
 
 The current database handle. See L<DBI>.
 
+=item C<dbh_main>
+
+The main database handle. See L<DBI>.
+
 =item C<languages>
 
 Currently installed languages.
index 9e7172e2b566f4cb4f2e6f6278ae324d9e3f40bb..1046cf2c3aebcf6b5c0444cbddb3d3cdb6cb1211 100644 (file)
@@ -43,9 +43,11 @@ sub new {
     }
 
     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(
         databases => [{
-            dsn    => Bugzilla->dbh->{private_bz_dsn},
+            dsn    => Bugzilla->dbh_main->{private_bz_dsn},
             user   => $lc->{db_user},
             pass   => $lc->{db_pass},
             prefix => 'ts_',