summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Bugzilla.pm25
-rwxr-xr-xbuglist.cgi2
-rwxr-xr-xcollectstats.pl6
-rwxr-xr-xduplicates.cgi3
-rwxr-xr-xreport.cgi3
-rwxr-xr-xshowdependencygraph.cgi4
-rwxr-xr-xshowdependencytree.cgi4
-rwxr-xr-xwhine.pl4
8 files changed, 17 insertions, 34 deletions
diff --git a/Bugzilla.pm b/Bugzilla.pm
index de30d8c99..501290992 100644
--- a/Bugzilla.pm
+++ b/Bugzilla.pm
@@ -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.
diff --git a/buglist.cgi b/buglist.cgi
index f39bb14b8..c46141638 100755
--- a/buglist.cgi
+++ b/buglist.cgi
@@ -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
diff --git a/collectstats.pl b/collectstats.pl
index a12c85586..e087c28d0 100755
--- a/collectstats.pl
+++ b/collectstats.pl
@@ -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 " .
diff --git a/duplicates.cgi b/duplicates.cgi
index 07bddc688..10ba5bf2b 100755
--- a/duplicates.cgi
+++ b/duplicates.cgi
@@ -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);
diff --git a/report.cgi b/report.cgi
index 4e2152542..7286c551e 100755
--- a/report.cgi
+++ b/report.cgi
@@ -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';
diff --git a/showdependencygraph.cgi b/showdependencygraph.cgi
index 0bdaab3e6..8f94aa918 100755
--- a/showdependencygraph.cgi
+++ b/showdependencygraph.cgi
@@ -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;
diff --git a/showdependencytree.cgi b/showdependencytree.cgi
index 3e4c4bf88..d9d71b0ab 100755
--- a/showdependencytree.cgi
+++ b/showdependencytree.cgi
@@ -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 #
diff --git a/whine.pl b/whine.pl
index 52e584011..0c8815368 100755
--- 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();
}
################################################################################