use Debbugs::Config qw(:config);
use Debbugs::Common qw(:lock buglog make_list get_hashname);
-use Debbugs::Status qw(bug_archiveable :read :hook);
+use Debbugs::Status qw(bug_archiveable :read :hook writebug);
use Debbugs::CGI qw(html_escape);
use Debbugs::Log qw(:misc);
use Params::Validate qw(validate_with :types);
use File::Path qw(mkpath);
use IO::File;
+use IO::Scalar;
-# These are a set of options which are common to all of these functions
+use Debbugs::Text qw(:templates);
+
+use Debbugs::Mail qw(rfc822_date);
+
+use POSIX qw(strftime);
+
+# These are a set of options which are common to all of these functions
my %common_options = (debug => {type => SCALARREF,
optional => 1,
%append_action_options,
},
);
+ our $locks = 0;
+ local $SIG{__DIE__} = sub {
+ if ($locks) {
+ for (1..$locks) { unfilelock(); }
+ $locks = 0;
+ }
+ };
my $action = "$config{bug} archived.";
my ($debug,$transcript) = __handle_debug_transcript(%param);
if ($param{check_archiveable} and
die "Bug $param{bug} cannot be archived";
}
print {$debug} "$param{bug} considering\n";
- my ($locks, $data) = lockreadbugmerge($param{bug});
+ my ($data);
+ ($locks, $data) = lockreadbugmerge($param{bug});
print {$debug} "$param{bug} read $locks\n";
defined $data or die "No bug found for $param{bug}";
print {$debug} "$param{bug} read ok (done $data->{done})\n";
}
if (not exists $param{message}) {
$action = $param{action} if exists $param{action};
- $param{message} = <<END;
-Received: (at fakecontrol) by fakecontrolmessage;
-To: $param{request_addr}
-From: $param{requester}
-Subject: Internal Control
-Message-Id: $action
-User-Agent: Fakemail v42.6.9
-
-# A New Hope
-# A log time ago, in a galaxy far, far away
-# something happened.
-#
-# Magically this resulted in the following
-# action being taken, but this fake control
-# message doesn't tell you why it happened
-#
-# The action:
-# $action
-thanks
-# This fakemail brought to you by your local debbugs
-# administrator
-END
+ my $date = rfc822_date();
+ $param{message} = fill_in_template(template => 'mail/fake_control_message',
+ variables => {request_addr => $param{request_addr},
+ requester => $param{requester},
+ date => $date,
+ action => $action
+ },
+ );
}
return (action => $action,
%param);