From 6c926fc14f987a047f1db3a793556f98f271b9f2 Mon Sep 17 00:00:00 2001 From: "terry%mozilla.org" <> Date: Wed, 26 May 1999 02:22:30 +0000 Subject: Avoid mid-air collisions (implementing a suggestion by py8ieh=bugzilla@bath.ac.uk). --- CGI.pl | 46 ++++++++++++++++++++++++++++++++++++++++++++++ bug_form.pl | 8 ++++++-- process_bug.cgi | 43 +++++++++++++++++++++++++++++++++++++++++-- show_activity.cgi | 29 +---------------------------- 4 files changed, 94 insertions(+), 32 deletions(-) diff --git a/CGI.pl b/CGI.pl index 68bb7edca..1b122aa73 100644 --- a/CGI.pl +++ b/CGI.pl @@ -509,6 +509,52 @@ sub PutHeader { } +sub DumpBugActivity { + my ($id, $starttime) = (@_); + my $datepart = ""; + if (defined $starttime) { + $datepart = "and bugs_activity.when >= $starttime"; + } + my $query = " + select bugs_activity.field, bugs_activity.when, + bugs_activity.oldvalue, bugs_activity.newvalue, + profiles.login_name + from bugs_activity,profiles + where bugs_activity.bug_id = $id $datepart + and profiles.userid = bugs_activity.who + order by bugs_activity.when"; + + SendSQL($query); + + print "\n"; + print "\n"; + print " \n"; + print "\n"; + + my @row; + while (@row = FetchSQLData()) { + my ($field,$when,$old,$new,$who) = (@row); + $old = value_quote($old); + $new = value_quote($new); + if ($old eq "") { + $old = " "; + } + if ($new eq "") { + $new = " "; + } + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + } + print "
WhoWhatOld valueNew valueWhen
$who$field$old$new$when
\n"; +} + + + diff --git a/bug_form.pl b/bug_form.pl index 14ec779a6..1c9ecb1e0 100644 --- a/bug_form.pl +++ b/bug_form.pl @@ -126,7 +126,8 @@ select qa_contact, status_whiteboard, date_format(creation_ts,'Y-m-d'), - groupset + groupset, + delta_ts from bugs where bug_id = $::FORM{'id'} and bugs.groupset & $::usergroupset = bugs.groupset"; @@ -141,7 +142,7 @@ if (@row = FetchSQLData()) { "bug_severity", "component", "assigned_to", "reporter", "bug_file_loc", "short_desc", "target_milestone", "qa_contact", "status_whiteboard", "creation_ts", - "groupset") { + "groupset", "delta_ts") { $bug{$field} = shift @row; if (!defined $bug{$field}) { $bug{$field} = ""; @@ -172,6 +173,7 @@ if (@row = FetchSQLData()) { $bug{'assigned_to'} = DBID_to_name($bug{'assigned_to'}); $bug{'reporter'} = DBID_to_name($bug{'reporter'}); $bug{'long_desc'} = GetLongDescription($::FORM{'id'}); +my $longdesclength = length($bug{'long_desc'}); GetVersionTable(); @@ -206,6 +208,8 @@ print " Bug $::FORM{'id'} -- " . html_quote($bug{'short_desc'}) . "
+ + diff --git a/process_bug.cgi b/process_bug.cgi index c671a90c2..3c1852d1d 100755 --- a/process_bug.cgi +++ b/process_bug.cgi @@ -260,12 +260,15 @@ if ($::comma eq "") { } my $basequery = $::query; +my $delta_ts; sub SnapShotBug { my ($id) = (@_); - SendSQL("select " . join(',', @::log_columns) . + SendSQL("select delta_ts, " . join(',', @::log_columns) . " from bugs where bug_id = $id"); - return FetchSQLData(); + my @row = FetchSQLData(); + $delta_ts = shift @row; + return @row; } @@ -273,6 +276,42 @@ foreach my $id (@idlist) { SendSQL("lock tables bugs write, bugs_activity write, cc write, profiles write"); my @oldvalues = SnapShotBug($id); + if (defined $::FORM{'delta_ts'} && $::FORM{'delta_ts'} ne $delta_ts) { + print " +

Mid-air collision detected!

+Someone else has made changes to this bug at the same time you were trying to. +The changes made were: +

+"; + DumpBugActivity($id, $delta_ts); + my $longdesc = GetLongDescription($id); + my $longchanged = 0; + if (length($longdesc) > $::FORM{'longdesclength'}) { + $longchanged = 1; + print "

Added text to the long description:

";
+            print html_quote(substr($longdesc, $::FORM{'longdesclength'}));
+            print "
\n"; + } + SendSQL("unlock tables"); + print "You have the following choices: \n}; + navigation_header(); + exit; + } + + + my $query = "$basequery\nwhere bug_id = $id"; # print "
$query
\n"; diff --git a/show_activity.cgi b/show_activity.cgi index 70f4c253f..fbcdcc687 100755 --- a/show_activity.cgi +++ b/show_activity.cgi @@ -29,35 +29,8 @@ print "Content-type: text/html\n\n"; PutHeader("Changes made to bug $::FORM{'id'}", "Activity log", "Bug $::FORM{'id'}"); -my $query = " - select bugs_activity.field, bugs_activity.when, - bugs_activity.oldvalue, bugs_activity.newvalue, - profiles.login_name - from bugs_activity,profiles - where bugs_activity.bug_id = $::FORM{'id'} - and profiles.userid = bugs_activity.who - order by bugs_activity.when"; - ConnectToDatabase(); -SendSQL($query); -print "
\n"; -print "\n"; -print " \n"; -print "\n"; +DumpBugActivity($::FORM{'id'}); -my @row; -while (@row = FetchSQLData()) { - my ($field,$when,$old,$new,$who) = (@row); - $old = value_quote($old); - $new = value_quote($new); - print "\n"; - print "\n"; - print "\n"; - print "\n"; - print "\n"; - print "\n"; - print "\n"; -} -print "
WhoWhatOld valueNew valueWhen
$who$field$old$new$when
\n"; print "
Back to bug $::FORM{'id'}\n"; -- cgit v1.2.3-24-g4f1b