Commit b2b03103 authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 471880: More scripts should use the shadow DB instead of the master DB -…

Bug 471880: More scripts should use the shadow DB instead of the master DB - Patch by Fré©ric Buclin <LpSolit@gmail.com> r=mkanat a=LpSolit
parent 812ad9b3
......@@ -46,6 +46,9 @@ if (Bugzilla->params->{'requirelogin'} && !$user->id) {
display_data();
}
# Get data from the shadow DB as they don't change very often.
Bugzilla->switch_to_shadow_db;
# Pass a bunch of Bugzilla configuration to the templates.
my $vars = {};
$vars->{'priority'} = get_legal_field_values('priority');
......
......@@ -32,14 +32,15 @@ use Bugzilla::Error;
use Bugzilla::Product;
my $user = Bugzilla->login();
my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh;
my $template = Bugzilla->template;
my $vars = {};
print $cgi->header();
# This script does nothing but displaying mostly static data.
Bugzilla->switch_to_shadow_db;
my $product_name = trim($cgi->param('product') || '');
my $product = new Bugzilla::Product({'name' => $product_name});
......
......@@ -35,6 +35,9 @@ my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
my $vars = {};
# Run queries against the shadow DB.
Bugzilla->switch_to_shadow_db;
$vars->{'keywords'} = Bugzilla::Keyword->get_all_with_bug_count();
$vars->{'caneditkeywords'} = Bugzilla->user->in_group("editkeywords");
......
......@@ -96,6 +96,9 @@ if ($cgi->param('nukedefaultquery')) {
$buffer = "";
}
# We are done with changes committed to the DB.
$dbh = Bugzilla->switch_to_shadow_db;
my $userdefaultquery;
if ($userid) {
$userdefaultquery = $dbh->selectrow_array(
......
......@@ -42,6 +42,8 @@ use Bugzilla::Component;
# Make sure the user is logged in.
my $user = Bugzilla->login();
my $cgi = Bugzilla->cgi;
# Force the script to run against the shadow DB. We already validated credentials.
Bugzilla->switch_to_shadow_db;
my $template = Bugzilla->template;
my $action = $cgi->param('action') || '';
......@@ -94,7 +96,6 @@ exit;
sub queue {
my $cgi = Bugzilla->cgi;
# There are some user privilege checks to do. We do them against the main DB.
my $dbh = Bugzilla->dbh;
my $template = Bugzilla->template;
my $user = Bugzilla->user;
......@@ -164,9 +165,7 @@ sub queue {
$query .= " AND flags.status = '?' " unless $status;
# The set of criteria by which we filter records to display in the queue.
# We now move to the shadow DB to query the DB.
my @criteria = ();
$dbh = Bugzilla->switch_to_shadow_db;
# A list of columns to exclude from the report because the report conditions
# limit the data being displayed to exact matches for those columns.
......@@ -304,9 +303,6 @@ sub queue {
my $flagtypes = get_flag_types();
push(@types, @$flagtypes);
# We move back to the main DB to get the list of products the user can see.
$dbh = Bugzilla->switch_to_main_db;
$vars->{'products'} = $user->get_selectable_products;
$vars->{'excluded_columns'} = \@excluded_columns;
$vars->{'group_field'} = $form_group;
......
......@@ -50,6 +50,10 @@ my $bug = Bugzilla::Bug->check($id);
# End Data/Security Validation
###############################################################################
# Run queries against the shadow DB. In the worst case, new changes are not
# visible immediately due to replication lag.
Bugzilla->switch_to_shadow_db;
($vars->{'operations'}, $vars->{'incomplete_data'}) =
Bugzilla::Bug::GetBugActivity($bug->id);
......
......@@ -55,6 +55,11 @@ my $format = $template->get_format("bug/show", scalar $cgi->param('format'),
my @bugs = ();
my %marks;
# If the user isn't logged in, we use data from the shadow DB. If he plans
# to edit the bug(s), he will have to log in first, meaning that the data
# will be reloaded anyway, from the main DB.
Bugzilla->switch_to_shadow_db unless $user->id;
if ($single) {
my $id = $cgi->param('id');
push @bugs, Bugzilla::Bug->check($id);
......
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