diff options
author | lpsolit%gmail.com <> | 2007-11-30 02:49:12 +0100 |
---|---|---|
committer | lpsolit%gmail.com <> | 2007-11-30 02:49:12 +0100 |
commit | f394b2ed4f175bf6076747ba7792e182841091ab (patch) | |
tree | d4ca1fcead500fd8edb40179e468423684fb7332 /attachment.cgi | |
parent | 5c9cb1c442e10faad5d5234f9c90f2a4529297be (diff) | |
download | bugzilla-f394b2ed4f175bf6076747ba7792e182841091ab.tar.gz bugzilla-f394b2ed4f175bf6076747ba7792e182841091ab.tar.xz |
Bug 99215: Attachments have no midair collision protection - Patch by Frédéric Buclin <LpSolit@gmail.com> r=mkanat r=justdave a=justdave
Diffstat (limited to 'attachment.cgi')
-rwxr-xr-x | attachment.cgi | 26 |
1 files changed, 24 insertions, 2 deletions
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. |