Commit 24c32fe3 authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 415155: Remove $cgi from the list of arguments when calling Bugzilla::Flag…

Bug 415155: Remove $cgi from the list of arguments when calling Bugzilla::Flag subroutines - Patch by Fré©ric Buclin <LpSolit@gmail.com> a=LpSolit
parent a9053d2b
...@@ -890,7 +890,7 @@ sub insert_attachment_for_bug { ...@@ -890,7 +890,7 @@ sub insert_attachment_for_bug {
foreach my $obsolete_attachment (@obsolete_attachments) { foreach my $obsolete_attachment (@obsolete_attachments) {
# If the obsolete attachment has request flags, cancel them. # If the obsolete attachment has request flags, cancel them.
# This call must be done before updating the 'attachments' table. # This call must be done before updating the 'attachments' table.
Bugzilla::Flag::CancelRequests($bug, $obsolete_attachment, $timestamp); Bugzilla::Flag->CancelRequests($bug, $obsolete_attachment, $timestamp);
$dbh->do('UPDATE attachments SET isobsolete = 1, modification_time = ? $dbh->do('UPDATE attachments SET isobsolete = 1, modification_time = ?
WHERE attach_id = ?', WHERE attach_id = ?',
...@@ -917,8 +917,8 @@ sub insert_attachment_for_bug { ...@@ -917,8 +917,8 @@ sub insert_attachment_for_bug {
my $error_mode_cache = Bugzilla->error_mode; my $error_mode_cache = Bugzilla->error_mode;
Bugzilla->error_mode(ERROR_MODE_DIE); Bugzilla->error_mode(ERROR_MODE_DIE);
eval { eval {
Bugzilla::Flag::validate($cgi, $bug->bug_id, -1, SKIP_REQUESTEE_ON_ERROR); Bugzilla::Flag::validate($bug->bug_id, -1, SKIP_REQUESTEE_ON_ERROR);
Bugzilla::Flag->process($bug, $attachment, $timestamp, $cgi, $hr_vars); Bugzilla::Flag->process($bug, $attachment, $timestamp, $hr_vars);
}; };
Bugzilla->error_mode($error_mode_cache); Bugzilla->error_mode($error_mode_cache);
if ($@) { if ($@) {
......
...@@ -246,7 +246,7 @@ sub count { ...@@ -246,7 +246,7 @@ sub count {
=over =over
=item C<validate($cgi, $bug_id, $attach_id, $skip_requestee_on_error)> =item C<validate($bug_id, $attach_id, $skip_requestee_on_error)>
Validates fields containing flag modifications. Validates fields containing flag modifications.
...@@ -258,8 +258,8 @@ to -1 to force its check anyway. ...@@ -258,8 +258,8 @@ to -1 to force its check anyway.
=cut =cut
sub validate { sub validate {
my ($cgi, $bug_id, $attach_id, $skip_requestee_on_error) = @_; my ($bug_id, $attach_id, $skip_requestee_on_error) = @_;
my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
# Get a list of flags to validate. Uses the "map" function # Get a list of flags to validate. Uses the "map" function
...@@ -501,22 +501,22 @@ sub snapshot { ...@@ -501,22 +501,22 @@ sub snapshot {
=over =over
=item C<process($bug, $attachment, $timestamp, $cgi, $hr_vars)> =item C<process($bug, $attachment, $timestamp, $hr_vars)>
Processes changes to flags. Processes changes to flags.
The bug and/or the attachment objects are the ones this flag is about, The bug and/or the attachment objects are the ones this flag is about,
the timestamp is the date/time the bug was last touched (so that changes the timestamp is the date/time the bug was last touched (so that changes
to the flag can be stamped with the same date/time), the cgi is the CGI to the flag can be stamped with the same date/time).
object used to obtain the flag fields that the user submitted.
=back =back
=cut =cut
sub process { sub process {
my ($class, $bug, $attachment, $timestamp, $cgi, $hr_vars) = @_; my ($class, $bug, $attachment, $timestamp, $hr_vars) = @_;
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
my $cgi = Bugzilla->cgi;
# Make sure the bug (and attachment, if given) exists and is accessible # Make sure the bug (and attachment, if given) exists and is accessible
# to the current user. Moreover, if an attachment object is passed, # to the current user. Moreover, if an attachment object is passed,
...@@ -535,7 +535,7 @@ sub process { ...@@ -535,7 +535,7 @@ sub process {
# Cancel pending requests if we are obsoleting an attachment. # Cancel pending requests if we are obsoleting an attachment.
if ($attachment && $cgi->param('isobsolete')) { if ($attachment && $cgi->param('isobsolete')) {
CancelRequests($bug, $attachment); $class->CancelRequests($bug, $attachment);
} }
# Create new flags and update existing flags. # Create new flags and update existing flags.
...@@ -1094,7 +1094,7 @@ sub notify { ...@@ -1094,7 +1094,7 @@ sub notify {
# Cancel all request flags from the attachment being obsoleted. # Cancel all request flags from the attachment being obsoleted.
sub CancelRequests { sub CancelRequests {
my ($bug, $attachment, $timestamp) = @_; my ($class, $bug, $attachment, $timestamp) = @_;
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
my $request_ids = my $request_ids =
...@@ -1109,7 +1109,7 @@ sub CancelRequests { ...@@ -1109,7 +1109,7 @@ sub CancelRequests {
return if (!scalar(@$request_ids)); return if (!scalar(@$request_ids));
# Take a snapshot of flags before any changes. # Take a snapshot of flags before any changes.
my @old_summaries = __PACKAGE__->snapshot($bug->bug_id, $attachment->id) my @old_summaries = $class->snapshot($bug->bug_id, $attachment->id)
if ($timestamp); if ($timestamp);
my $flags = Bugzilla::Flag->new_from_list($request_ids); my $flags = Bugzilla::Flag->new_from_list($request_ids);
foreach my $flag (@$flags) { clear($flag, $bug, $attachment) } foreach my $flag (@$flags) { clear($flag, $bug, $attachment) }
...@@ -1118,7 +1118,7 @@ sub CancelRequests { ...@@ -1118,7 +1118,7 @@ sub CancelRequests {
return unless ($timestamp); return unless ($timestamp);
# Take a snapshot of flags after any changes. # Take a snapshot of flags after any changes.
my @new_summaries = __PACKAGE__->snapshot($bug->bug_id, $attachment->id); my @new_summaries = $class->snapshot($bug->bug_id, $attachment->id);
update_activity($bug->bug_id, $attachment->id, $timestamp, update_activity($bug->bug_id, $attachment->id, $timestamp,
\@old_summaries, \@new_summaries); \@old_summaries, \@new_summaries);
} }
......
...@@ -508,7 +508,7 @@ sub update { ...@@ -508,7 +508,7 @@ sub update {
Bugzilla::User::match_field($cgi, { Bugzilla::User::match_field($cgi, {
'^requestee(_type)?-(\d+)$' => { 'type' => 'multi' } '^requestee(_type)?-(\d+)$' => { 'type' => 'multi' }
}); });
Bugzilla::Flag::validate($cgi, $bug->id, $attachment->id); Bugzilla::Flag::validate($bug->id, $attachment->id);
# Start a transaction in preparation for updating the attachment. # Start a transaction in preparation for updating the attachment.
$dbh->bz_start_transaction(); $dbh->bz_start_transaction();
...@@ -529,7 +529,7 @@ sub update { ...@@ -529,7 +529,7 @@ sub update {
# to attachments so that we can delete pending requests if the user # to attachments so that we can delete pending requests if the user
# is obsoleting this attachment without deleting any requests # is obsoleting this attachment without deleting any requests
# the user submits at the same time. # the user submits at the same time.
Bugzilla::Flag->process($bug, $attachment, $timestamp, $cgi, $vars); Bugzilla::Flag->process($bug, $attachment, $timestamp, $vars);
# Update the attachment record in the database. # Update the attachment record in the database.
$dbh->do("UPDATE attachments $dbh->do("UPDATE attachments
......
...@@ -229,8 +229,8 @@ if (defined($cgi->upload('data')) || $cgi->param('attachurl')) { ...@@ -229,8 +229,8 @@ if (defined($cgi->upload('data')) || $cgi->param('attachurl')) {
my $error_mode_cache = Bugzilla->error_mode; my $error_mode_cache = Bugzilla->error_mode;
Bugzilla->error_mode(ERROR_MODE_DIE); Bugzilla->error_mode(ERROR_MODE_DIE);
eval { eval {
Bugzilla::Flag::validate($cgi, $id, undef, SKIP_REQUESTEE_ON_ERROR); Bugzilla::Flag::validate($id, undef, SKIP_REQUESTEE_ON_ERROR);
Bugzilla::Flag->process($bug, undef, $timestamp, $cgi, $vars); Bugzilla::Flag->process($bug, undef, $timestamp, $vars);
}; };
Bugzilla->error_mode($error_mode_cache); Bugzilla->error_mode($error_mode_cache);
if ($@) { if ($@) {
......
...@@ -162,7 +162,7 @@ if (defined $cgi->param('dontchange')) { ...@@ -162,7 +162,7 @@ if (defined $cgi->param('dontchange')) {
# Validate flags in all cases. validate() should not detect any # Validate flags in all cases. validate() should not detect any
# reference to flags if $cgi->param('id') is undefined. # reference to flags if $cgi->param('id') is undefined.
Bugzilla::Flag::validate($cgi, $cgi->param('id')); Bugzilla::Flag::validate($cgi->param('id'));
###################################################################### ######################################################################
# End Data/Security Validation # End Data/Security Validation
...@@ -550,7 +550,7 @@ foreach my $bug (@bug_objects) { ...@@ -550,7 +550,7 @@ foreach my $bug (@bug_objects) {
} }
# Set and update flags. # Set and update flags.
Bugzilla::Flag->process($bug, undef, $timestamp, $cgi, $vars); Bugzilla::Flag->process($bug, undef, $timestamp, $vars);
$dbh->bz_commit_transaction(); $dbh->bz_commit_transaction();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment