From 25b150c3cac4cbf80eea41169235338c64d95c97 Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" Date: Sun, 13 Nov 2005 17:50:47 +0000 Subject: [PATCH] =?UTF-8?q?Bug=20313695:=20buglist.cgi=20and=20some=20othe?= =?UTF-8?q?r=20scripts=20do=20not=20use=20the=20shadow=20DB=20anymore=20-?= =?UTF-8?q?=20Patch=20by=20Fr=C3=A9d=C3=A9ric=20Buclin=20=20r/a=3Djustdave?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://10.0.0.236/trunk@184545 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/webtools/bugzilla/Bugzilla.pm | 25 ++++++------------- mozilla/webtools/bugzilla/buglist.cgi | 2 +- mozilla/webtools/bugzilla/collectstats.pl | 6 ++--- mozilla/webtools/bugzilla/duplicates.cgi | 3 +-- mozilla/webtools/bugzilla/report.cgi | 3 +-- .../webtools/bugzilla/showdependencygraph.cgi | 4 +-- .../webtools/bugzilla/showdependencytree.cgi | 4 +-- mozilla/webtools/bugzilla/whine.pl | 4 +-- 8 files changed, 17 insertions(+), 34 deletions(-) diff --git a/mozilla/webtools/bugzilla/Bugzilla.pm b/mozilla/webtools/bugzilla/Bugzilla.pm index de30d8c99b4..50129099293 100644 --- a/mozilla/webtools/bugzilla/Bugzilla.pm +++ b/mozilla/webtools/bugzilla/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. -=item C - -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 from using the main database to using the shadow database. diff --git a/mozilla/webtools/bugzilla/buglist.cgi b/mozilla/webtools/bugzilla/buglist.cgi index f39bb14b805..c46141638e8 100755 --- a/mozilla/webtools/bugzilla/buglist.cgi +++ b/mozilla/webtools/bugzilla/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/mozilla/webtools/bugzilla/collectstats.pl b/mozilla/webtools/bugzilla/collectstats.pl index a12c85586cf..e087c28d046 100755 --- a/mozilla/webtools/bugzilla/collectstats.pl +++ b/mozilla/webtools/bugzilla/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/mozilla/webtools/bugzilla/duplicates.cgi b/mozilla/webtools/bugzilla/duplicates.cgi index 07bddc68816..10ba5bf2b8d 100755 --- a/mozilla/webtools/bugzilla/duplicates.cgi +++ b/mozilla/webtools/bugzilla/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/mozilla/webtools/bugzilla/report.cgi b/mozilla/webtools/bugzilla/report.cgi index 4e215254276..7286c551e67 100755 --- a/mozilla/webtools/bugzilla/report.cgi +++ b/mozilla/webtools/bugzilla/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/mozilla/webtools/bugzilla/showdependencygraph.cgi b/mozilla/webtools/bugzilla/showdependencygraph.cgi index 0bdaab3e650..8f94aa918a0 100755 --- a/mozilla/webtools/bugzilla/showdependencygraph.cgi +++ b/mozilla/webtools/bugzilla/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/mozilla/webtools/bugzilla/showdependencytree.cgi b/mozilla/webtools/bugzilla/showdependencytree.cgi index 3e4c4bf8830..d9d71b0abc4 100755 --- a/mozilla/webtools/bugzilla/showdependencytree.cgi +++ b/mozilla/webtools/bugzilla/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/mozilla/webtools/bugzilla/whine.pl b/mozilla/webtools/bugzilla/whine.pl index 52e5840119e..0c8815368eb 100755 --- a/mozilla/webtools/bugzilla/whine.pl +++ b/mozilla/webtools/bugzilla/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(); } ################################################################################