]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 313695: buglist.cgi and some other scripts do not use the shadow DB correctly...
authorlpsolit%gmail.com <>
Mon, 14 Nov 2005 01:57:26 +0000 (01:57 +0000)
committerlpsolit%gmail.com <>
Mon, 14 Nov 2005 01:57:26 +0000 (01:57 +0000)
Bugzilla.pm
Bugzilla/User.pm
buglist.cgi
collectstats.pl
whine.pl

index 0deb6e16e56e1ac328f6008c21e05df1275d9e85..c46b8f80637f65f22fa2bbd541ff4b1a86a698fc 100644 (file)
@@ -144,12 +144,20 @@ sub switch_to_shadow_db {
     }
 
     $_dbh = $_dbh_shadow;
+    # we have to return $class->dbh instead of $_dbh as
+    # $_dbh_shadow may be undefined if no shadow DB is used
+    # and no connection to the main DB has been established yet.
+    return $class->dbh;
 }
 
 sub switch_to_main_db {
     my $class = shift;
 
     $_dbh = $_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;
 }
 
 # Private methods
index 252275991e014ecbc5ae8660ade7c93af9a0a8d7..87b82171bd6423b4af2203cb8ddd92d85a4b59ac 100644 (file)
@@ -149,11 +149,11 @@ sub _create {
     if ($result) {
         my $is_main_db;
         unless ($is_main_db = Bugzilla->dbwritesallowed()) {
-            Bugzilla->switch_to_main_db();
+            $dbh = Bugzilla->switch_to_main_db();
         }
         $self->derive_groups($tables_locked_for_derive_groups);
         unless ($is_main_db) {
-            Bugzilla->switch_to_shadow_db();
+            $dbh = Bugzilla->switch_to_shadow_db();
         }
     }
 
index cc087fe67e59eb4c499cb3615ba6cf3c3df18f3a..461f7f8bfb507be542021343bc9660697c99f3ff 100755 (executable)
@@ -836,7 +836,7 @@ if ($serverpush) {
 
 # Connect to the shadow database if this installation is using one to improve
 # query performance.
-Bugzilla->switch_to_shadow_db();
+$dbh = Bugzilla->switch_to_shadow_db();
 
 # Normally, we ignore SIGTERM and SIGPIPE (see globals.pl) but we need to
 # respond to them here to prevent someone DOSing us by reloading a query
index a12c85586cf05ef7d8bf3796ca24687b51c90261..e087c28d046adc35c3e7bbda713c5b02b64f1117 100755 (executable)
@@ -458,10 +458,8 @@ sub CollectSeriesData {
 
     # We save a copy of the main $dbh and then switch to the shadow and get
     # that one too. Remember, these may be the same.
-    Bugzilla->switch_to_main_db();
-    my $dbh = Bugzilla->dbh;
-    Bugzilla->switch_to_shadow_db();
-    my $shadow_dbh = Bugzilla->dbh;
+    my $dbh = Bugzilla->switch_to_main_db();
+    my $shadow_dbh = Bugzilla->switch_to_shadow_db();
     
     my $serieses = $dbh->selectall_hashref("SELECT series_id, query, creator " .
                       "FROM series " .
index d8fc8ddd08b66f03d4ea77045ad9a749e2950c52..4068a052f612dde30658e36f6515f44867cf9482 100755 (executable)
--- a/whine.pl
+++ b/whine.pl
@@ -327,7 +327,7 @@ while (my $event = get_next_event) {
 
     # We loop for each target user because some of the queries will be using
     # subjective pronouns
-    Bugzilla->switch_to_shadow_db();
+    $dbh = Bugzilla->switch_to_shadow_db();
     for my $target (@{$event->{'mailto'}}) {
         my $args = {
             'subject'     => $event->{'subject'},
@@ -352,7 +352,7 @@ while (my $event = get_next_event) {
 
         mail($args);
     }
-    Bugzilla->switch_to_main_db();
+    $dbh = Bugzilla->switch_to_main_db();
 }
 
 ################################################################################