Commit 03352ccf authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 313695: buglist.cgi and some other scripts do not use the shadow DB anymore…

Bug 313695: buglist.cgi and some other scripts do not use the shadow DB anymore - Patch by Frédéric Buclin <LpSolit@gmail.com> r/a=justdave
parent e4fa5195
...@@ -242,17 +242,6 @@ sub batch { ...@@ -242,17 +242,6 @@ sub batch {
return $_batch || 0; 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 { sub switch_to_shadow_db {
my $class = shift; my $class = shift;
...@@ -265,12 +254,20 @@ sub switch_to_shadow_db { ...@@ -265,12 +254,20 @@ sub switch_to_shadow_db {
} }
$_dbh = $_dbh_shadow; $_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 { sub switch_to_main_db {
my $class = shift; my $class = shift;
$_dbh = $_dbh_main; $_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 # Private methods
...@@ -440,12 +437,6 @@ Bugzilla->batch will return the current state of this flag. ...@@ -440,12 +437,6 @@ Bugzilla->batch will return the current state of this flag.
The current database handle. See L<DBI>. 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> =item C<switch_to_shadow_db>
Switch from using the main database to using the shadow database. Switch from using the main database to using the shadow database.
......
...@@ -870,7 +870,7 @@ if ($serverpush) { ...@@ -870,7 +870,7 @@ if ($serverpush) {
# Connect to the shadow database if this installation is using one to improve # Connect to the shadow database if this installation is using one to improve
# query performance. # 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 # 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 # respond to them here to prevent someone DOSing us by reloading a query
......
...@@ -458,10 +458,8 @@ sub CollectSeriesData { ...@@ -458,10 +458,8 @@ sub CollectSeriesData {
# We save a copy of the main $dbh and then switch to the shadow and get # 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. # that one too. Remember, these may be the same.
Bugzilla->switch_to_main_db(); my $dbh = Bugzilla->switch_to_main_db();
my $dbh = Bugzilla->dbh; my $shadow_dbh = Bugzilla->switch_to_shadow_db();
Bugzilla->switch_to_shadow_db();
my $shadow_dbh = Bugzilla->dbh;
my $serieses = $dbh->selectall_hashref("SELECT series_id, query, creator " . my $serieses = $dbh->selectall_hashref("SELECT series_id, query, creator " .
"FROM series " . "FROM series " .
......
...@@ -37,7 +37,6 @@ use Bugzilla::Config qw(:DEFAULT $datadir); ...@@ -37,7 +37,6 @@ use Bugzilla::Config qw(:DEFAULT $datadir);
use Bugzilla::Constants; use Bugzilla::Constants;
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh;
# Go directly to the XUL version of the duplicates report (duplicates.xul) # 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 # if the user specified ctype=xul. Adds params if they exist, and directs
...@@ -66,7 +65,7 @@ else { ...@@ -66,7 +65,7 @@ else {
Bugzilla->login(); Bugzilla->login();
} }
Bugzilla->switch_to_shadow_db(); my $dbh = Bugzilla->switch_to_shadow_db();
use vars qw (@legal_product); use vars qw (@legal_product);
......
...@@ -35,7 +35,6 @@ my $cgi = Bugzilla->cgi; ...@@ -35,7 +35,6 @@ my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template; my $template = Bugzilla->template;
my $vars = {}; my $vars = {};
my $buffer = $cgi->query_string(); my $buffer = $cgi->query_string();
my $dbh = Bugzilla->dbh;
# Go straight back to query.cgi if we are adding a boolean chart. # Go straight back to query.cgi if we are adding a boolean chart.
if (grep(/^cmd-/, $cgi->param())) { if (grep(/^cmd-/, $cgi->param())) {
...@@ -53,7 +52,7 @@ GetVersionTable(); ...@@ -53,7 +52,7 @@ GetVersionTable();
Bugzilla->login(LOGIN_REQUIRED); Bugzilla->login(LOGIN_REQUIRED);
Bugzilla->switch_to_shadow_db(); my $dbh = Bugzilla->switch_to_shadow_db();
my $action = $cgi->param('action') || 'menu'; my $action = $cgi->param('action') || 'menu';
......
...@@ -36,13 +36,11 @@ require "globals.pl"; ...@@ -36,13 +36,11 @@ require "globals.pl";
Bugzilla->login(); Bugzilla->login();
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh;
my $template = Bugzilla->template; my $template = Bugzilla->template;
my $vars = {}; my $vars = {};
# Connect to the shadow database if this installation is using one to improve # Connect to the shadow database if this installation is using one to improve
# performance. # performance.
Bugzilla->switch_to_shadow_db(); my $dbh = Bugzilla->switch_to_shadow_db();
my %seen; my %seen;
my %edgesdone; my %edgesdone;
......
...@@ -33,13 +33,11 @@ use Bugzilla::Bug; ...@@ -33,13 +33,11 @@ use Bugzilla::Bug;
Bugzilla->login(); Bugzilla->login();
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh;
my $template = Bugzilla->template; my $template = Bugzilla->template;
my $vars = {}; my $vars = {};
# Connect to the shadow database if this installation is using one to improve # Connect to the shadow database if this installation is using one to improve
# performance. # performance.
Bugzilla->switch_to_shadow_db(); my $dbh = Bugzilla->switch_to_shadow_db();
################################################################################ ################################################################################
# Data/Security Validation # # Data/Security Validation #
......
...@@ -323,7 +323,7 @@ while (my $event = get_next_event) { ...@@ -323,7 +323,7 @@ while (my $event = get_next_event) {
# We loop for each target user because some of the queries will be using # We loop for each target user because some of the queries will be using
# subjective pronouns # subjective pronouns
Bugzilla->switch_to_shadow_db(); $dbh = Bugzilla->switch_to_shadow_db();
for my $target (@{$event->{'mailto'}}) { for my $target (@{$event->{'mailto'}}) {
my $args = { my $args = {
'subject' => $event->{'subject'}, 'subject' => $event->{'subject'},
...@@ -348,7 +348,7 @@ while (my $event = get_next_event) { ...@@ -348,7 +348,7 @@ while (my $event = get_next_event) {
mail($args); mail($args);
} }
Bugzilla->switch_to_main_db(); $dbh = Bugzilla->switch_to_main_db();
} }
################################################################################ ################################################################################
......
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