From f394b2ed4f175bf6076747ba7792e182841091ab Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Fri, 30 Nov 2007 01:49:12 +0000 Subject: Bug 99215: Attachments have no midair collision protection - Patch by Frédéric Buclin r=mkanat r=justdave a=justdave MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- attachment.cgi | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'attachment.cgi') diff --git a/attachment.cgi b/attachment.cgi index 23841571c..768653c31 100755 --- a/attachment.cgi +++ b/attachment.cgi @@ -460,6 +460,27 @@ sub update { $cgi->param('isobsolete', $cgi->param('isobsolete') ? 1 : 0); $cgi->param('isprivate', $cgi->param('isprivate') ? 1 : 0); + # Now make sure the attachment has not been edited since we loaded the page. + if (defined $cgi->param('delta_ts') + && $cgi->param('delta_ts') ne $attachment->modification_time) + { + ($vars->{'operations'}) = + Bugzilla::Bug::GetBugActivity($bug->id, $attachment->id, $cgi->param('delta_ts')); + + # If the modification date changed but there is no entry in + # the activity table, this means someone commented only. + # In this case, there is no reason to midair. + if (scalar(@{$vars->{'operations'}})) { + $cgi->param('delta_ts', $attachment->modification_time); + $vars->{'attachment'} = $attachment; + + print $cgi->header(); + # Warn the user about the mid-air collision and ask them what to do. + $template->process("attachment/midair.html.tmpl", $vars) + || ThrowTemplateError($template->error()); + exit; + } + } # If the submitter of the attachment is not in the insidergroup, # be sure that he cannot overwrite the private bit. # This check must be done before calling Bugzilla::Flag*::validate(), @@ -507,11 +528,12 @@ sub update { filename = ?, ispatch = ?, isobsolete = ?, - isprivate = ? + isprivate = ?, + modification_time = ? WHERE attach_id = ?", undef, ($description, $contenttype, $filename, $cgi->param('ispatch'), $cgi->param('isobsolete'), - $cgi->param('isprivate'), $attachment->id)); + $cgi->param('isprivate'), $timestamp, $attachment->id)); my $updated_attachment = Bugzilla::Attachment->get($attachment->id); # Record changes in the activity table. -- cgit v1.2.3-24-g4f1b