summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlpsolit%gmail.com <>2009-01-25 13:42:51 +0100
committerlpsolit%gmail.com <>2009-01-25 13:42:51 +0100
commitb2b03103bba9927d5f1b123e0ad7ae1e04149dc8 (patch)
treee4845cde1af1ada8ca0d43e8c42be6d589e9a936
parent812ad9b3515aff6d9d870c2a11845b7416e40288 (diff)
downloadbugzilla-b2b03103bba9927d5f1b123e0ad7ae1e04149dc8.tar.gz
bugzilla-b2b03103bba9927d5f1b123e0ad7ae1e04149dc8.tar.xz
Bug 471880: More scripts should use the shadow DB instead of the master DB - Patch by Frédéric Buclin <LpSolit@gmail.com> r=mkanat a=LpSolit
-rwxr-xr-xconfig.cgi3
-rwxr-xr-xdescribecomponents.cgi5
-rwxr-xr-xdescribekeywords.cgi3
-rwxr-xr-xquery.cgi3
-rwxr-xr-xrequest.cgi8
-rwxr-xr-xshow_activity.cgi4
-rwxr-xr-xshow_bug.cgi5
7 files changed, 23 insertions, 8 deletions
diff --git a/config.cgi b/config.cgi
index c229dacd6..282b95957 100755
--- a/config.cgi
+++ b/config.cgi
@@ -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');
diff --git a/describecomponents.cgi b/describecomponents.cgi
index 806183783..6d4722ad8 100755
--- a/describecomponents.cgi
+++ b/describecomponents.cgi
@@ -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});
diff --git a/describekeywords.cgi b/describekeywords.cgi
index 5ff5c5089..9796b77d5 100755
--- a/describekeywords.cgi
+++ b/describekeywords.cgi
@@ -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");
diff --git a/query.cgi b/query.cgi
index f41310bb7..a3e3445b8 100755
--- a/query.cgi
+++ b/query.cgi
@@ -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(
diff --git a/request.cgi b/request.cgi
index 666b74b17..5dfb76ddb 100755
--- a/request.cgi
+++ b/request.cgi
@@ -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;
diff --git a/show_activity.cgi b/show_activity.cgi
index f7db3dd0b..27096018f 100755
--- a/show_activity.cgi
+++ b/show_activity.cgi
@@ -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);
diff --git a/show_bug.cgi b/show_bug.cgi
index 62575c5ce..0578733be 100755
--- a/show_bug.cgi
+++ b/show_bug.cgi
@@ -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);