severity => [qw(set_severity)],
affects => [qw(affects)],
summary => [qw(summary)],
+ outlook => [qw(outlook)],
owner => [qw(owner)],
title => [qw(set_title)],
forward => [qw(set_forwarded)],
clone => [qw(clone_bug)],
archive => [qw(bug_archive bug_unarchive),
],
+ limit => [qw(check_limit)],
log => [qw(append_action_to_log),
],
);
}
use Debbugs::Config qw(:config);
-use Debbugs::Common qw(:lock buglog :misc get_hashname sort_versions);
+use Debbugs::Common qw(:lock buglog :misc get_hashname sort_versions :utf8);
use Debbugs::Status qw(bug_archiveable :read :hook writebug new_bug splitpackages split_status_fields get_bug_status);
use Debbugs::CGI qw(html_escape);
use Debbugs::Log qw(:misc :write);
use Storable qw(dclone nfreeze);
use List::Util qw(first max);
+use Encode qw(encode_utf8);
use Carp;
for my $data (@data) {
my $old_data = dclone($data);
my $hash = get_hashname($data->{bug_num});
- my $report_fh = IO::File->new("db-h/$hash/$data->{bug_num}.report",'r') or
- die "Unable to open original report db-h/$hash/$data->{bug_num}.report for reading: $!";
+ my $report_fh = IO::File->new("$config{spool_dir}/db-h/$hash/$data->{bug_num}.report",'r') or
+ die "Unable to open original report $config{spool_dir}/db-h/$hash/$data->{bug_num}.report for reading: $!";
my $orig_report;
{
local $/;
headers =>
[To => $data->{submitter},
Subject => "$config{ubug}#$data->{bug_num} ".
- "closed by $param{requester} ($param{request_subject})",
+ "closed by $param{requester} ".(defined $param{request_subject}?"($param{request_subject})":""),
],
)
],
$new_locks += $n_locks;
%data = %{$data};
@data = values %data;
- if (not __check_limit(data => [@data],
+ if (not check_limit(data => [@data],
exists $param{limit}?(limit => $param{limit}):(),
transcript => $transcript,
)) {
# look like. However, if merge is set, tags, fixed and found
# are merged.
if ($data->{bug_num} == $master_bug) {
- for (qw(package forwarded severity blocks blockedby done owner summary affects)) {
+ for (qw(package forwarded severity blocks blockedby done owner summary outlook affects)) {
$merge_status{$_} = $data->{$_}
}
}
key => 'summary',
options => [],
},
+ outlook => {func => \&outlook,
+ key => 'outlook',
+ options => [],
+ },
affects => {func => \&affects,
key => 'package',
options => [],
allowed => 1,
},
);
- for my $field (qw(forwarded severity blocks blockedby done owner summary affects package fixed_versions found_versions keywords)) {
+ for my $field (qw(forwarded severity blocks blockedby done owner summary outlook affects package fixed_versions found_versions keywords)) {
# if the ideal bug already has the field set properly, we
# continue on.
if ($field eq 'keywords'){
sub summary {
- my %param = validate_with(params => \@_,
+ # outlook and summary are exactly the same, basically
+ return _summary('summary',@_);
+}
+
+=head1 OUTLOOK FUNCTIONS
+
+=head2 outlook
+
+ eval {
+ outlook(bug => $ref,
+ transcript => $transcript,
+ ($dl > 0 ? (debug => $transcript):()),
+ requester => $header{from},
+ request_addr => $controlrequestaddr,
+ message => \@log,
+ affected_packages => \%affected_packages,
+ recipients => \%recipients,
+ outlook => undef,
+ );
+ };
+ if ($@) {
+ $errors++;
+ print {$transcript} "Failed to mark $ref with outlook foo: $@";
+ }
+
+Handles all setting of outlook fields
+
+If outlook is undef, unsets the outlook
+
+If outlook is 0, sets the outlook to the first paragraph contained in
+the message passed.
+
+If outlook is a positive integer, sets the outlook to the message specified.
+
+Otherwise, sets outlook to the value passed.
+
+=cut
+
+
+sub outlook {
+ return _summary('outlook',@_);
+}
+
+sub _summary {
+ my ($cmd,@params) = @_;
+ my %param = validate_with(params => \@params,
spec => {bug => {type => SCALAR,
regex => qr/^\d+$/,
},
# specific options here
- summary => {type => SCALAR|UNDEF,
- default => 0,
- },
+ $cmd , {type => SCALAR|UNDEF,
+ default => 0,
+ },
%common_options,
%append_action_options,
},
);
-# croak "summary must be numeric or undef" if
-# defined $param{summary} and not $param{summary} =~ /^\d+/;
my %info =
__begin_control(%param,
- command => 'summary'
+ command => $cmd,
);
my ($debug,$transcript) =
@info{qw(debug transcript)};
my $summary = '';
my $summary_msg = '';
my $action = '';
- if (not defined $param{summary}) {
+ if (not defined $param{$cmd}) {
# do nothing
- print {$debug} "Removing summary fields\n";
- $action = 'Removed summary';
+ print {$debug} "Removing $cmd fields\n";
+ $action = "Removed $cmd";
}
- elsif ($param{summary} =~ /^\d+$/) {
+ elsif ($param{$cmd} =~ /^\d+$/) {
my $log = [];
my @records = Debbugs::Log::read_log_records(bug_num => $param{bug});
- if ($param{summary} == 0) {
+ if ($param{$cmd} == 0) {
$log = $param{message};
$summary_msg = @records + 1;
}
else {
- if (($param{summary} - 1 ) > $#records) {
- die "Message number '$param{summary}' exceeds the maximum message '$#records'";
+ if (($param{$cmd} - 1 ) > $#records) {
+ die "Message number '$param{$cmd}' exceeds the maximum message '$#records'";
}
- my $record = $records[($param{summary} - 1 )];
+ my $record = $records[($param{$cmd} - 1 )];
if ($record->{type} !~ /incoming-recv|recips/) {
- die "Message number '$param{summary}' is a invalid message type '$record->{type}'";
+ die "Message number '$param{$cmd}' is a invalid message type '$record->{type}'";
}
- $summary_msg = $param{summary};
+ $summary_msg = $param{$cmd};
$log = [$record->{text}];
}
my $p_o = Debbugs::MIME::parse(join('',@{$log}));
next if $in_pseudoheaders;
$paragraph .= $line ." \n";
}
- print {$debug} "Summary is going to be '$paragraph'\n";
+ print {$debug} ucfirst($cmd)." is going to be '$paragraph'\n";
$summary = $paragraph;
$summary =~ s/[\n\r]/ /g;
if (not length $summary) {
- die "Unable to find summary message to use";
+ die "Unable to find $cmd message to use";
}
# trim off a trailing spaces
$summary =~ s/\ *$//;
}
else {
- $summary = $param{summary};
+ $summary = $param{$cmd};
}
for my $data (@data) {
- print {$debug} "Going to change summary\n";
+ print {$debug} "Going to change $cmd\n";
if (((not defined $summary or not length $summary) and
- (not defined $data->{summary} or not length $data->{summary})) or
- $summary eq $data->{summary}) {
- print {$transcript} "Ignoring request to change the summary of bug $param{bug} to the same value\n";
+ (not defined $data->{$cmd} or not length $data->{$cmd})) or
+ $summary eq $data->{$cmd}) {
+ print {$transcript} "Ignoring request to change the $cmd of bug $param{bug} to the same value\n";
next;
}
if (length $summary) {
- if (length $data->{summary}) {
- $action = "Summary replaced with message bug $param{bug} message $summary_msg";
+ if (length $data->{$cmd}) {
+ $action = ucfirst($cmd)." replaced with message bug $param{bug} message $summary_msg";
}
else {
- $action = "Summary recorded from message bug $param{bug} message $summary_msg";
+ $action = ucfirst($cmd)." recorded from message bug $param{bug} message $summary_msg";
}
}
my $old_data = dclone($data);
- $data->{summary} = $summary;
+ $data->{$cmd} = $summary;
append_action_to_log(bug => $data->{bug_num},
- command => 'summary',
+ command => $cmd,
old_data => $old_data,
new_data => $data,
get_lock => 0,
for my $bug (split ' ', $data->{blocks}) {
for my $new_bug (@new_bugs) {
set_blocks(bug => $new_bug,
- blocks => $bug,
+ block => $bug,
hash_slice(%param,
keys %common_options,
keys %append_action_options),
for my $bug (split ' ', $data->{blockedby}) {
for my $new_bug (@new_bugs) {
set_blocks(bug => $bug,
- blocks => $new_bug,
+ block => $new_bug,
hash_slice(%param,
keys %common_options,
keys %append_action_options),
$nd{$key} = $new_data->{$key};
# $data_diff .= html_escape("$Debbugs::Status::fields{$key}: $new_data->{$key}")."\n";
}
- $data_diff .= html_escape(Data::Dumper->Dump([\%nd],[qw(new_data)]));
+ $data_diff .= html_escape(Data::Dumper->Dump([encode_utf8_structure(\%nd)],[qw(new_data)]));
$data_diff .= "-->\n";
$data_diff .= "<!-- old_data:\n";
my %od;
$od{$key} = $old_data->{$key};
# $data_diff .= html_escape("$Debbugs::Status::fields{$key}: $old_data->{$key}")."\n";
}
- $data_diff .= html_escape(Data::Dumper->Dump([\%od],[qw(old_data)]));
+ $data_diff .= html_escape(Data::Dumper->Dump([encode_utf8_structure(\%od)],[qw(old_data)]));
$data_diff .= "-->\n";
}
my $msg = join('',
(exists $param{command} ?
- "<!-- command:".html_escape($param{command})." -->\n":""
+ "<!-- command:".html_escape(encode_utf8($param{command}))." -->\n":""
),
(length $param{requester} ?
- "<!-- requester: ".html_escape($param{requester})." -->\n":""
+ "<!-- requester: ".html_escape(encode_utf8($param{requester}))." -->\n":""
),
(length $param{request_addr} ?
- "<!-- request_addr: ".html_escape($param{request_addr})." -->\n":""
+ "<!-- request_addr: ".html_escape(encode_utf8($param{request_addr}))." -->\n":""
),
"<!-- time:".time()." -->\n",
$data_diff,
- "<strong>".html_escape($param{action})."</strong>\n");
+ "<strong>".html_escape(encode_utf8($param{action}))."</strong>\n");
if (length $param{requester}) {
- $msg .= "Request was from <code>".html_escape($param{requester})."</code>\n";
+ $msg .= "Request was from <code>".html_escape(encode_utf8($param{requester}))."</code>\n";
}
if (length $param{request_addr}) {
- $msg .= "to <code>".html_escape($param{request_addr})."</code>";
+ $msg .= "to <code>".html_escape(encode_utf8($param{request_addr}))."</code>";
}
if (length $param{desc}) {
- $msg .= ":<br>\n$param{desc}\n";
+ $msg .= ":<br>\n".encode_utf8($param{desc})."\n";
}
else {
$msg .= ".\n";
}
}
}
- if (not __check_limit(data => \@data,
+ if (not check_limit(data => \@data,
exists $param{limit}?(limit => $param{limit}):(),
transcript => $transcript,
)) {
}
-=head2 __check_limit
+=head2 check_limit
- __check_limit(data => \@data, limit => $param{limit});
+ check_limit(data => \@data, limit => $param{limit});
Checks to make sure that bugs match any limits; each entry of @data
=cut
-sub __check_limit{
+sub check_limit{
my %param = validate_with(params => \@_,
- spec => {data => {type => ARRAYREF|SCALAR,
+ spec => {data => {type => ARRAYREF|HASHREF,
},
limit => {type => HASHREF|UNDEF,
},
my $hole_var = {'&bugurl' =>
sub{"$_[0]: ".
'http://'.$config{cgi_domain}.'/'.
- Debbugs::CGI::bug_url($_[0]);
+ Debbugs::CGI::bug_links(bug => $_[0],
+ links_only => 1,
+ );
}
};