summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlpsolit%gmail.com <>2008-03-17 22:37:01 +0100
committerlpsolit%gmail.com <>2008-03-17 22:37:01 +0100
commitae5ac4fd14bdbaf73ca32969233c8d0c35532f80 (patch)
treeb103dd54a1599c61573c53a54271e9c22ae30bc2
parent781336a725598eaeb0fa6cfc65b38211b42118ba (diff)
downloadbugzilla-ae5ac4fd14bdbaf73ca32969233c8d0c35532f80.tar.gz
bugzilla-ae5ac4fd14bdbaf73ca32969233c8d0c35532f80.tar.xz
Bug 323003: [importxml.pl] attachments should be imported with the original creator - Patch by Frédéric Buclin <LpSolit@gmail.com> r=ghendricks a=LpSolit
-rwxr-xr-ximportxml.pl17
-rw-r--r--template/en/default/bug/show.xml.tmpl1
2 files changed, 17 insertions, 1 deletions
diff --git a/importxml.pl b/importxml.pl
index 04dd98625..8dcd4936b 100755
--- a/importxml.pl
+++ b/importxml.pl
@@ -362,6 +362,7 @@ sub process_attachment() {
$attachment{'isobsolete'} = $attach->{'att'}->{'isobsolete'} || 0;
$attachment{'isprivate'} = $attach->{'att'}->{'isprivate'} || 0;
$attachment{'filename'} = $attach->field('filename') || "file";
+ $attachment{'attacher'} = $attach->field('attacher');
# Attachment data is not exported in versions 2.20 and older.
if (defined $attach->first_child('data') &&
defined $attach->first_child('data')->{'att'}->{'encoding'}) {
@@ -1150,13 +1151,16 @@ sub process_bug {
$err .= " Marking attachment public\n";
$att->{'isprivate'} = 0;
}
+
+ my $attacher_id = $att->{'attacher'} ? login_to_id($att->{'attacher'}) : undef;
+
$dbh->do("INSERT INTO attachments
(bug_id, creation_ts, modification_time, filename, description,
mimetype, ispatch, isprivate, isobsolete, submitter_id)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
undef, $id, $att->{'date'}, $att->{'date'}, $att->{'filename'},
$att->{'desc'}, $att->{'ctype'}, $att->{'ispatch'},
- $att->{'isprivate'}, $att->{'isobsolete'}, $exporterid);
+ $att->{'isprivate'}, $att->{'isobsolete'}, $attacher_id || $exporterid);
my $att_id = $dbh->bz_last_key( 'attachments', 'attach_id' );
my $att_data = $att->{'data'};
my $sth = $dbh->prepare("INSERT INTO attach_data (id, thedata)
@@ -1164,7 +1168,18 @@ sub process_bug {
trick_taint($att_data);
$sth->bind_param( 1, $att_data, $dbh->BLOB_TYPE );
$sth->execute();
+
$comments .= "Imported an attachment (id=$att_id)\n";
+ if (!$attacher_id) {
+ if ($att->{'attacher'}) {
+ $err .= "The original submitter of attachment $att_id was\n ";
+ $err .= $att->{'attacher'} . ", but he doesn't have an account here.\n";
+ }
+ else {
+ $err .= "The original submitter of attachment $att_id is unknown.\n";
+ }
+ $err .= " Reassigning to the person who moved it here: $exporter_login.\n";
+ }
# Process attachment flags
foreach my $aflag (@{ $att->{'flags'} }) {
diff --git a/template/en/default/bug/show.xml.tmpl b/template/en/default/bug/show.xml.tmpl
index 8c490c076..714eee517 100644
--- a/template/en/default/bug/show.xml.tmpl
+++ b/template/en/default/bug/show.xml.tmpl
@@ -92,6 +92,7 @@
<filename>[% a.filename FILTER xml %]</filename>
<type>[% a.contenttype FILTER xml %]</type>
<size>[% a.datasize FILTER xml %]</size>
+ <attacher>[% a.attacher.email FILTER xml %]</attacher>
[% IF displayfields.attachmentdata %]
<data encoding="base64">[% a.data FILTER base64 %]</data>
[% END %]