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

index de30d8c99b42c25db35c713e3b21d8f270a8fb2e..5012909929398852f680e254811c5880336304ea 100644 (file)
@@ -242,17 +242,6 @@ sub batch {
     return $_batch || 0;
 }
 
-sub dbwritesallowed {
-    my $class = shift;
-
-    # We can write if we are connected to the main database.
-    # Note that if we don't have a shadowdb, then we claim that its ok
-    # to write even if we're nominally connected to the shadowdb.
-    # This is OK because this method is only used to test if misc
-    # updates can be done, rather than anything complicated.
-    return $class->dbh == $_dbh_main;
-}
-
 sub switch_to_shadow_db {
     my $class = shift;
 
@@ -265,12 +254,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
@@ -440,12 +437,6 @@ Bugzilla->batch will return the current state of this flag.
 
 The current database handle. See L<DBI>.
 
-=item C<dbwritesallowed>
-
-Determines if writes to the database are permitted. This is usually used to
-determine if some general cleanup needs to occur (such as clearing the token
-table)
-
 =item C<switch_to_shadow_db>
 
 Switch from using the main database to using the shadow database.
index f39bb14b805d2e62223a5b35d000fa08a5a4b5d4..c46141638e89e157bb77a284e4a13dacf4aba78e 100755 (executable)
@@ -870,7 +870,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 07bddc688168c1c6daeae6668dd0f7c83e88a772..10ba5bf2b8d7c06ab5d907e09c4ca6198c7bf8fe 100755 (executable)
@@ -37,7 +37,6 @@ use Bugzilla::Config qw(:DEFAULT $datadir);
 use Bugzilla::Constants;
 
 my $cgi = Bugzilla->cgi;
-my $dbh = Bugzilla->dbh;
 
 # Go directly to the XUL version of the duplicates report (duplicates.xul)
 # if the user specified ctype=xul.  Adds params if they exist, and directs
@@ -66,7 +65,7 @@ else {
     Bugzilla->login();
 }
 
-Bugzilla->switch_to_shadow_db();
+my $dbh = Bugzilla->switch_to_shadow_db();
 
 use vars qw (@legal_product);
 
index 4e2152542765fa073e827d766c83923d731c42fb..7286c551e67afe5569ece0017b3b06b411f8e58d 100755 (executable)
@@ -35,7 +35,6 @@ my $cgi = Bugzilla->cgi;
 my $template = Bugzilla->template;
 my $vars = {};
 my $buffer = $cgi->query_string();
-my $dbh = Bugzilla->dbh;
 
 # Go straight back to query.cgi if we are adding a boolean chart.
 if (grep(/^cmd-/, $cgi->param())) {
@@ -53,7 +52,7 @@ GetVersionTable();
 
 Bugzilla->login(LOGIN_REQUIRED);
 
-Bugzilla->switch_to_shadow_db();
+my $dbh = Bugzilla->switch_to_shadow_db();
 
 my $action = $cgi->param('action') || 'menu';
 
index 0bdaab3e65027ef48fa43c778decb7a347c369d1..8f94aa918a0ebf1e05b56da9cd275b52ff37abda 100755 (executable)
@@ -36,13 +36,11 @@ require "globals.pl";
 Bugzilla->login();
 
 my $cgi = Bugzilla->cgi;
-my $dbh = Bugzilla->dbh;
 my $template = Bugzilla->template;
 my $vars = {};
-
 # Connect to the shadow database if this installation is using one to improve
 # performance.
-Bugzilla->switch_to_shadow_db();
+my $dbh = Bugzilla->switch_to_shadow_db();
 
 my %seen;
 my %edgesdone;
index 3e4c4bf8830f546934632ccd15ca47b359103861..d9d71b0abc43ebeb1faf5a808c097aa096bd6efc 100755 (executable)
@@ -33,13 +33,11 @@ use Bugzilla::Bug;
 Bugzilla->login();
 
 my $cgi = Bugzilla->cgi;
-my $dbh = Bugzilla->dbh;
 my $template = Bugzilla->template;
 my $vars = {};
-
 # Connect to the shadow database if this installation is using one to improve
 # performance.
-Bugzilla->switch_to_shadow_db();
+my $dbh = Bugzilla->switch_to_shadow_db();
 
 ################################################################################
 # Data/Security Validation                                                     #
index 52e5840119e0639b6500bf5ab5fd91e425f477ab..0c8815368ebcb0335944fcbbf3cfc1811dc48d4f 100755 (executable)
--- a/whine.pl
+++ b/whine.pl
@@ -323,7 +323,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'},
@@ -348,7 +348,7 @@ while (my $event = get_next_event) {
 
         mail($args);
     }
-    Bugzilla->switch_to_main_db();
+    $dbh = Bugzilla->switch_to_main_db();
 }
 
 ################################################################################