Commit f4399fec authored by endico%mozilla.org's avatar endico%mozilla.org

experimental: Not part of normal bugzilla distibution. Bug.pm creates a bug…

experimental: Not part of normal bugzilla distibution. Bug.pm creates a bug object and provides methods for getting and setting attributes and for printing out the bug as xml. xml.cgi prompts for a list of bugs and displays the list as html. xml.cgi replaces export_bug.cgi
parent 9342a7c6
#!/usr/bonsaitools/bin/perl -w
# -*- Mode: perl; indent-tabs-mode: nil -*-
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Bugzilla Bug Tracking System.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): Dawn Endico <endico@mozilla.org>
# Terry Weissman <terry@mozilla.org>
use diagnostics;
use strict;
use DBI;
use RelationSet;
require "globals.pl";
require "CGI.pl";
package Bug;
use CGI::Carp qw(fatalsToBrowser);
my %bug;
my %ok_field;
for my $key (qw (bug_id product version rep_platform op_sys bug_status
resolution priority bug_severity component assigned_to
reporter bug_file_loc short_desc target_milestone
qa_contact status_whiteboard creation_ts groupset
delta_ts votes) ){
$ok_field{$key}++;
}
# create a new empty bug
#
sub new {
my $type = shift();
# create a ref to an empty hash and bless it
#
my $self = {%bug};
bless $self, $type;
# construct from a hash containing a bug's info
#
if ($#_ == 1) {
$self->initBug(@_);
} else {
confess("invalid number of arguments \($#_\)($_)");
}
# bless as a Bug
#
return $self;
}
# dump info about bug into hash unless user doesn't have permission
# user_id 0 is used when person is not logged in.
#
sub initBug {
my $self = shift();
my ($bug_id, $user_id) = (@_);
if ( (! defined $bug_id) || (!$bug_id) ) {
# no bug number given
return {};
}
if (! defined $user_id) {
$user_id = 0;
}
&::ConnectToDatabase();
&::GetVersionTable();
# this verification should already have been done by caller
# my $loginok = quietly_check_login();
my $usergroupset = "0";
if (defined $::usergroupset) {
$usergroupset = $::usergroupset;
}
my $query = "
select
bugs.bug_id, product, version, rep_platform, op_sys, bug_status,
resolution, priority, bug_severity, component, assigned_to, reporter,
bug_file_loc, short_desc, target_milestone, qa_contact,
status_whiteboard, date_format(creation_ts,'%Y-%m-%d %H:%i'),
groupset, delta_ts, sum(votes.count)
from bugs left join votes using(bug_id)
where bugs.bug_id = $bug_id
and bugs.groupset & $usergroupset = bugs.groupset
group by bugs.bug_id";
&::SendSQL($query);
my @row;
if (@row = &::FetchSQLData()) {
my $count = 0;
my %fields;
foreach my $field ("bug_id", "product", "version", "rep_platform",
"op_sys", "bug_status", "resolution", "priority",
"bug_severity", "component", "assigned_to", "reporter",
"bug_file_loc", "short_desc", "target_milestone",
"qa_contact", "status_whiteboard", "creation_ts",
"groupset", "delta_ts", "votes") {
$fields{$field} = shift @row;
if ($fields{$field}) {
$bug{$field} = $fields{$field};
}
$count++;
}
} else {
&::SendSQL("select groupset from bugs where bug_id = $bug_id");
if (@row = &::FetchSQLData()) {
$bug{'bug_id'} = $bug_id;
$bug{'error'} = "NotPermitted";
return $self;
} else {
$bug{'bug_id'} = $bug_id;
$bug{'error'} = "NotFound";
return $self;
}
}
if ($bug{'short_desc'}) {
$bug{'short_desc'} = QuoteXMLChars( $bug{'short_desc'} );
}
if (defined $bug{'status_whiteboard'}) {
$bug{'status_whiteboard'} = QuoteXMLChars($bug{'status_whiteboard'});
}
$bug{'assigned_to'} = &::DBID_to_real_or_loginname($bug{'assigned_to'});
$bug{'reporter'} = &::DBID_to_real_or_loginname($bug{'reporter'});
my $ccSet = new RelationSet;
$ccSet->mergeFromDB("select who from cc where bug_id=$bug_id");
my @cc = $ccSet->toArrayOfStrings();
if (@cc) {
$bug{'cc'} = \@cc;
}
if (&::Param("useqacontact") && (defined $bug{'qa_contact'}) ) {
my $name = $bug{'qa_contact'} > 0 ? &::DBID_to_name($bug{'qa_contact'}) :"";
if ($name) {
$bug{'qa_contact'} = $name;
}
}
if (@::legal_keywords) {
&::SendSQL("SELECT keyworddefs.name
FROM keyworddefs, keywords
WHERE keywords.bug_id = $bug_id
AND keyworddefs.id = keywords.keywordid
ORDER BY keyworddefs.name");
my @list;
while (&::MoreSQLData()) {
push(@list, &::FetchOneColumn());
}
if (@list) {
$bug{'keywords'} = &::html_quote(join(', ', @list));
}
}
&::SendSQL("select attach_id, creation_ts, description
from attachments
where bug_id = $bug_id");
my @attachments;
while (&::MoreSQLData()) {
my ($attachid, $date, $desc) = (&::FetchSQLData());
if ($date =~ /^(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/) {
$date = "$3/$4/$2 $5:$6";
my %attach;
$attach{'attachid'} = $attachid;
$attach{'date'} = $date;
$attach{'desc'} = &::html_quote($desc);
push @attachments, \%attach;
}
}
if (@attachments) {
$bug{'attachments'} = \@attachments;
}
&::SendSQL("select bug_id, who, bug_when, thetext
from longdescs
where bug_id = $bug_id");
my @longdescs;
while (&::MoreSQLData()) {
my ($bug_id, $who, $bug_when, $thetext) = (&::FetchSQLData());
my %longdesc;
$longdesc{'who'} = $who;
$longdesc{'bug_when'} = $bug_when;
$longdesc{'thetext'} = &::html_quote($thetext);
push @longdescs, \%longdesc;
}
if (@longdescs) {
$bug{'longdescs'} = \@longdescs;
}
if (&::Param("usedependencies")) {
my @depends = EmitDependList("blocked", "dependson", $bug_id);
if ( @depends ) {
$bug{'dependson'} = \@depends;
}
my @blocks = EmitDependList("dependson", "blocked", $bug_id);
if ( @blocks ) {
$bug{'blocks'} = \@blocks;
}
}
return $self;
}
# given a bug hash, emit xml for it. with file header provided by caller
#
sub emitXML {
( $#_ == 0 ) || confess("invalid number of arguments");
my $self = shift();
my $xml;
if (exists $bug{'error'}) {
$xml .= "<bug error=\"$bug{'error'}\">\n";
$xml .= " <bug_id>$bug{'bug_id'}</bug_id>\n";
$xml .= "</bug>\n";
return $xml;
}
$xml .= "<bug>\n";
foreach my $field ("bug_id", "urlbase", "bug_status", "product",
"priority", "version", "rep_platform", "assigned_to", "delta_ts",
"component", "reporter", "target_milestone", "bug_severity",
"creation_ts", "qa_contact", "op_sys", "resolution", "bug_file_loc",
"short_desc", "keywords", "status_whiteboard") {
if ($bug{$field}) {
$xml .= " <$field>" . $bug{$field} . "</$field>\n";
}
}
foreach my $field ("dependson", "blocks", "cc") {
if (defined $bug{$field}) {
for (my $i=0 ; $i < @{$bug{$field}} ; $i++) {
$xml .= " <$field>" . $bug{$field}[$i] . "</$field>\n";
}
}
}
if (defined $bug{'longdescs'}) {
for (my $i=0 ; $i < @{$bug{'longdescs'}} ; $i++) {
$xml .= " <long_desc>\n";
$xml .= " <who>" . &::DBID_to_name($bug{'longdescs'}[$i]->{'who'})
. "</who>\n";
$xml .= " <bug_when>" . $bug{'longdescs'}[$i]->{'bug_when'}
. "</bug_when>\n";
$xml .= " <thetext>" . QuoteXMLChars($bug{'longdescs'}[$i]->{'thetext'})
. "</thetext>\n";
$xml .= " </long_desc>\n";
}
}
if (defined $bug{'attachments'}) {
for (my $i=0 ; $i < @{$bug{'attachments'}} ; $i++) {
$xml .= " <attachment>\n";
$xml .= " <attachid>" . $bug{'attachments'}[$i]->{'attachid'}
. "</attachid>\n";
$xml .= " <date>" . $bug{'attachments'}[$i]->{'date'} . "</date>\n";
$xml .= " <desc>" . $bug{'attachments'}[$i]->{'desc'} . "</desc>\n";
# $xml .= " <type>" . $bug{'attachments'}[$i]->{'type'} . "</type>\n";
# $xml .= " <data>" . $bug{'attachments'}[$i]->{'data'} . "</data>\n";
$xml .= " </attachment>\n";
}
}
$xml .= "</bug>\n";
return $xml;
}
sub EmitDependList {
my ($myfield, $targetfield, $bug_id) = (@_);
my @list;
&::SendSQL("select dependencies.$targetfield, bugs.bug_status
from dependencies, bugs
where dependencies.$myfield = $bug_id
and bugs.bug_id = dependencies.$targetfield
order by dependencies.$targetfield");
while (&::MoreSQLData()) {
my ($i, $stat) = (&::FetchSQLData());
push @list, $i;
}
return @list;
}
sub QuoteXMLChars {
$_[0] =~ s/</&lt;/g;
$_[0] =~ s/>/&gt;/g;
$_[0] =~ s/'/&apos;/g;
$_[0] =~ s/"/&quot;/g;
$_[0] =~ s/&/&amp;/g;
# $_[0] =~ s/([\x80-\xFF])/&XmlUtf8Encode(ord($1))/ge;
return($_[0]);
}
sub XML_Header {
my ($urlbase, $version, $maintainer, $exporter) = (@_);
my $xml;
$xml = "<?xml version=\"1.0\" standalone=\"no\"?>\n";
$xml .= "<!DOCTYPE bugzilla SYSTEM \"$urlbase";
if (! ($urlbase =~ /.+\/$/)) {
$xml .= "/";
}
$xml .= "bugzilla.dtd\">\n";
$xml .= "<bugzilla";
if (defined $exporter) {
$xml .= " exporter=\"$exporter\"";
}
$xml .= " version=\"$version\"";
$xml .= " urlbase=\"$urlbase\"";
$xml .= " maintainer=\"$maintainer\">\n";
return ($xml);
}
sub XML_Footer {
return ("</bugzilla>\n");
}
sub AUTOLOAD {
use vars qw($AUTOLOAD);
my $self = shift;
my $type = ref($self) || $self;
my $attr = $AUTOLOAD;
$attr =~ s/.*:://;
return unless $attr=~ /[^A-Z]/;
if (@_) {
$bug{$attr} = shift;
return;
}
confess "invalid bug attribute $attr" unless $ok_field{$attr};
if (defined $bug{$attr}) {
return $bug{$attr};
} else {
return '';
}
}
1;
#!/usr/bonsaitools/bin/perl -w
# -*- Mode: perl; indent-tabs-mode: nil -*-
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Bugzilla Bug Tracking System.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): Dawn Endico <endico@mozilla.org>
# Terry Weissman <terry@mozilla.org>
use diagnostics;
use strict;
use DBI;
use RelationSet;
require "globals.pl";
require "CGI.pl";
package Bug;
use CGI::Carp qw(fatalsToBrowser);
my %bug;
my %ok_field;
for my $key (qw (bug_id product version rep_platform op_sys bug_status
resolution priority bug_severity component assigned_to
reporter bug_file_loc short_desc target_milestone
qa_contact status_whiteboard creation_ts groupset
delta_ts votes) ){
$ok_field{$key}++;
}
# create a new empty bug
#
sub new {
my $type = shift();
# create a ref to an empty hash and bless it
#
my $self = {%bug};
bless $self, $type;
# construct from a hash containing a bug's info
#
if ($#_ == 1) {
$self->initBug(@_);
} else {
confess("invalid number of arguments \($#_\)($_)");
}
# bless as a Bug
#
return $self;
}
# dump info about bug into hash unless user doesn't have permission
# user_id 0 is used when person is not logged in.
#
sub initBug {
my $self = shift();
my ($bug_id, $user_id) = (@_);
if ( (! defined $bug_id) || (!$bug_id) ) {
# no bug number given
return {};
}
if (! defined $user_id) {
$user_id = 0;
}
&::ConnectToDatabase();
&::GetVersionTable();
# this verification should already have been done by caller
# my $loginok = quietly_check_login();
my $usergroupset = "0";
if (defined $::usergroupset) {
$usergroupset = $::usergroupset;
}
my $query = "
select
bugs.bug_id, product, version, rep_platform, op_sys, bug_status,
resolution, priority, bug_severity, component, assigned_to, reporter,
bug_file_loc, short_desc, target_milestone, qa_contact,
status_whiteboard, date_format(creation_ts,'%Y-%m-%d %H:%i'),
groupset, delta_ts, sum(votes.count)
from bugs left join votes using(bug_id)
where bugs.bug_id = $bug_id
and bugs.groupset & $usergroupset = bugs.groupset
group by bugs.bug_id";
&::SendSQL($query);
my @row;
if (@row = &::FetchSQLData()) {
my $count = 0;
my %fields;
foreach my $field ("bug_id", "product", "version", "rep_platform",
"op_sys", "bug_status", "resolution", "priority",
"bug_severity", "component", "assigned_to", "reporter",
"bug_file_loc", "short_desc", "target_milestone",
"qa_contact", "status_whiteboard", "creation_ts",
"groupset", "delta_ts", "votes") {
$fields{$field} = shift @row;
if ($fields{$field}) {
$bug{$field} = $fields{$field};
}
$count++;
}
} else {
&::SendSQL("select groupset from bugs where bug_id = $bug_id");
if (@row = &::FetchSQLData()) {
$bug{'bug_id'} = $bug_id;
$bug{'error'} = "NotPermitted";
return $self;
} else {
$bug{'bug_id'} = $bug_id;
$bug{'error'} = "NotFound";
return $self;
}
}
if ($bug{'short_desc'}) {
$bug{'short_desc'} = QuoteXMLChars( $bug{'short_desc'} );
}
if (defined $bug{'status_whiteboard'}) {
$bug{'status_whiteboard'} = QuoteXMLChars($bug{'status_whiteboard'});
}
$bug{'assigned_to'} = &::DBID_to_real_or_loginname($bug{'assigned_to'});
$bug{'reporter'} = &::DBID_to_real_or_loginname($bug{'reporter'});
my $ccSet = new RelationSet;
$ccSet->mergeFromDB("select who from cc where bug_id=$bug_id");
my @cc = $ccSet->toArrayOfStrings();
if (@cc) {
$bug{'cc'} = \@cc;
}
if (&::Param("useqacontact") && (defined $bug{'qa_contact'}) ) {
my $name = $bug{'qa_contact'} > 0 ? &::DBID_to_name($bug{'qa_contact'}) :"";
if ($name) {
$bug{'qa_contact'} = $name;
}
}
if (@::legal_keywords) {
&::SendSQL("SELECT keyworddefs.name
FROM keyworddefs, keywords
WHERE keywords.bug_id = $bug_id
AND keyworddefs.id = keywords.keywordid
ORDER BY keyworddefs.name");
my @list;
while (&::MoreSQLData()) {
push(@list, &::FetchOneColumn());
}
if (@list) {
$bug{'keywords'} = &::html_quote(join(', ', @list));
}
}
&::SendSQL("select attach_id, creation_ts, description
from attachments
where bug_id = $bug_id");
my @attachments;
while (&::MoreSQLData()) {
my ($attachid, $date, $desc) = (&::FetchSQLData());
if ($date =~ /^(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/) {
$date = "$3/$4/$2 $5:$6";
my %attach;
$attach{'attachid'} = $attachid;
$attach{'date'} = $date;
$attach{'desc'} = &::html_quote($desc);
push @attachments, \%attach;
}
}
if (@attachments) {
$bug{'attachments'} = \@attachments;
}
&::SendSQL("select bug_id, who, bug_when, thetext
from longdescs
where bug_id = $bug_id");
my @longdescs;
while (&::MoreSQLData()) {
my ($bug_id, $who, $bug_when, $thetext) = (&::FetchSQLData());
my %longdesc;
$longdesc{'who'} = $who;
$longdesc{'bug_when'} = $bug_when;
$longdesc{'thetext'} = &::html_quote($thetext);
push @longdescs, \%longdesc;
}
if (@longdescs) {
$bug{'longdescs'} = \@longdescs;
}
if (&::Param("usedependencies")) {
my @depends = EmitDependList("blocked", "dependson", $bug_id);
if ( @depends ) {
$bug{'dependson'} = \@depends;
}
my @blocks = EmitDependList("dependson", "blocked", $bug_id);
if ( @blocks ) {
$bug{'blocks'} = \@blocks;
}
}
return $self;
}
# given a bug hash, emit xml for it. with file header provided by caller
#
sub emitXML {
( $#_ == 0 ) || confess("invalid number of arguments");
my $self = shift();
my $xml;
if (exists $bug{'error'}) {
$xml .= "<bug error=\"$bug{'error'}\">\n";
$xml .= " <bug_id>$bug{'bug_id'}</bug_id>\n";
$xml .= "</bug>\n";
return $xml;
}
$xml .= "<bug>\n";
foreach my $field ("bug_id", "urlbase", "bug_status", "product",
"priority", "version", "rep_platform", "assigned_to", "delta_ts",
"component", "reporter", "target_milestone", "bug_severity",
"creation_ts", "qa_contact", "op_sys", "resolution", "bug_file_loc",
"short_desc", "keywords", "status_whiteboard") {
if ($bug{$field}) {
$xml .= " <$field>" . $bug{$field} . "</$field>\n";
}
}
foreach my $field ("dependson", "blocks", "cc") {
if (defined $bug{$field}) {
for (my $i=0 ; $i < @{$bug{$field}} ; $i++) {
$xml .= " <$field>" . $bug{$field}[$i] . "</$field>\n";
}
}
}
if (defined $bug{'longdescs'}) {
for (my $i=0 ; $i < @{$bug{'longdescs'}} ; $i++) {
$xml .= " <long_desc>\n";
$xml .= " <who>" . &::DBID_to_name($bug{'longdescs'}[$i]->{'who'})
. "</who>\n";
$xml .= " <bug_when>" . $bug{'longdescs'}[$i]->{'bug_when'}
. "</bug_when>\n";
$xml .= " <thetext>" . QuoteXMLChars($bug{'longdescs'}[$i]->{'thetext'})
. "</thetext>\n";
$xml .= " </long_desc>\n";
}
}
if (defined $bug{'attachments'}) {
for (my $i=0 ; $i < @{$bug{'attachments'}} ; $i++) {
$xml .= " <attachment>\n";
$xml .= " <attachid>" . $bug{'attachments'}[$i]->{'attachid'}
. "</attachid>\n";
$xml .= " <date>" . $bug{'attachments'}[$i]->{'date'} . "</date>\n";
$xml .= " <desc>" . $bug{'attachments'}[$i]->{'desc'} . "</desc>\n";
# $xml .= " <type>" . $bug{'attachments'}[$i]->{'type'} . "</type>\n";
# $xml .= " <data>" . $bug{'attachments'}[$i]->{'data'} . "</data>\n";
$xml .= " </attachment>\n";
}
}
$xml .= "</bug>\n";
return $xml;
}
sub EmitDependList {
my ($myfield, $targetfield, $bug_id) = (@_);
my @list;
&::SendSQL("select dependencies.$targetfield, bugs.bug_status
from dependencies, bugs
where dependencies.$myfield = $bug_id
and bugs.bug_id = dependencies.$targetfield
order by dependencies.$targetfield");
while (&::MoreSQLData()) {
my ($i, $stat) = (&::FetchSQLData());
push @list, $i;
}
return @list;
}
sub QuoteXMLChars {
$_[0] =~ s/</&lt;/g;
$_[0] =~ s/>/&gt;/g;
$_[0] =~ s/'/&apos;/g;
$_[0] =~ s/"/&quot;/g;
$_[0] =~ s/&/&amp;/g;
# $_[0] =~ s/([\x80-\xFF])/&XmlUtf8Encode(ord($1))/ge;
return($_[0]);
}
sub XML_Header {
my ($urlbase, $version, $maintainer, $exporter) = (@_);
my $xml;
$xml = "<?xml version=\"1.0\" standalone=\"no\"?>\n";
$xml .= "<!DOCTYPE bugzilla SYSTEM \"$urlbase";
if (! ($urlbase =~ /.+\/$/)) {
$xml .= "/";
}
$xml .= "bugzilla.dtd\">\n";
$xml .= "<bugzilla";
if (defined $exporter) {
$xml .= " exporter=\"$exporter\"";
}
$xml .= " version=\"$version\"";
$xml .= " urlbase=\"$urlbase\"";
$xml .= " maintainer=\"$maintainer\">\n";
return ($xml);
}
sub XML_Footer {
return ("</bugzilla>\n");
}
sub AUTOLOAD {
use vars qw($AUTOLOAD);
my $self = shift;
my $type = ref($self) || $self;
my $attr = $AUTOLOAD;
$attr =~ s/.*:://;
return unless $attr=~ /[^A-Z]/;
if (@_) {
$bug{$attr} = shift;
return;
}
confess "invalid bug attribute $attr" unless $ok_field{$attr};
if (defined $bug{$attr}) {
return $bug{$attr};
} else {
return '';
}
}
1;
...@@ -295,7 +295,7 @@ foreach my $field ("bug_id", "urlbase", "bug_status", "product", "priority", ...@@ -295,7 +295,7 @@ foreach my $field ("bug_id", "urlbase", "bug_status", "product", "priority",
"version", "rep_platform", "assigned_to", "delta_ts", "component", "version", "rep_platform", "assigned_to", "delta_ts", "component",
"reporter", "target_milestone", "bug_severity", "creation_ts", "reporter", "target_milestone", "bug_severity", "creation_ts",
"qa_contact", "op_sys", "resolution", "bug_file_loc", "short_desc", "qa_contact", "op_sys", "resolution", "bug_file_loc", "short_desc",
"keywords", "status_whiteboard") { "keywords", "groupset", "status_whiteboard") {
if ($bug{$field}) { if ($bug{$field}) {
$xml .= " <$field>" . $bug{$field} . "</$field>\n"; $xml .= " <$field>" . $bug{$field} . "</$field>\n";
} }
......
...@@ -28,6 +28,9 @@ ...@@ -28,6 +28,9 @@
use diagnostics; use diagnostics;
use strict; use strict;
use XML::Parser; use XML::Parser;
use Data::Dumper;
$Data::Dumper::Useqq = 1;
require "CGI.pl"; require "CGI.pl";
require "globals.pl"; require "globals.pl";
...@@ -107,181 +110,200 @@ if ( ! $exporterid ) { ...@@ -107,181 +110,200 @@ if ( ! $exporterid ) {
} }
my %multiple_fields; my $bugqty = ($#{@{$tree}->[1]} +1 -3) / 4;
foreach my $field (qw (dependson cc long_desc blocks)) { print "Importing $bugqty bugs from $urlbase,\n sent by $exporter.\n";
for (my $k=1 ; $k <= $bugqty ; $k++) {
my $cur = $k*4;
if (defined $tree->[1][$cur][0]->{'error'}) {
print "\nError in bug $tree->[1][$cur][4][2]\@$urlbase:";
print " $tree->[1][$cur][0]->{'error'}\n";
if ($tree->[1][$cur][0]->{'error'} =~ /NotFound/) {
print "$exporter tried to move bug $tree->[1][$cur][4][2] here";
print " but $urlbase reports that this bug does not exist.\n";
} elsif ( $tree->[1][$cur][0]->{'error'} =~ /NotPermitted/) {
print "$exporter tried to move bug $tree->[1][$cur][4][2] here";
print " but $urlbase reports that $exporter does not have access";
print " to that bug.\n";
}
next;
}
my %multiple_fields;
foreach my $field (qw (dependson cc long_desc blocks)) {
$multiple_fields{$field} = "x"; $multiple_fields{$field} = "x";
} }
my %all_fields; my %all_fields;
foreach my $field (qw (dependson product bug_status priority cc version foreach my $field (qw (dependson product bug_status priority cc version
bug_id rep_platform short_desc assigned_to resolution bug_id rep_platform short_desc assigned_to resolution
delta_ts component reporter urlbase target_milestone bug_severity delta_ts component reporter urlbase target_milestone bug_severity
creation_ts qa_contact keyword status_whiteboard op_sys blocks)) { creation_ts qa_contact keyword status_whiteboard op_sys blocks)) {
$all_fields{$field} = "x"; $all_fields{$field} = "x";
} }
my %bug_fields; my %bug_fields;
my $err = ""; my $err = "";
for (my $i=3 ; $i < $#{@{$tree}->[1][4]} ; $i=$i+4) { for (my $i=3 ; $i < $#{@{$tree}->[1][$cur]} ; $i=$i+4) {
if (defined $multiple_fields{$tree->[1][4][$i]}) { if (defined $multiple_fields{$tree->[1][$cur][$i]}) {
if (defined $bug_fields{$tree->[1][4][$i]}) { if (defined $bug_fields{$tree->[1][$cur][$i]}) {
$bug_fields{$tree->[1][4][$i]} .= " " . $tree->[1][4][$i+1][2]; $bug_fields{$tree->[1][$cur][$i]} .= " " . $tree->[1][$cur][$i+1][2];
} else { } else {
$bug_fields{$tree->[1][4][$i]} = $tree->[1][4][$i+1][2]; $bug_fields{$tree->[1][$cur][$i]} = $tree->[1][$cur][$i+1][2];
} }
} elsif (defined $all_fields{$tree->[1][4][$i]}) { } elsif (defined $all_fields{$tree->[1][$cur][$i]}) {
$bug_fields{$tree->[1][4][$i]} = $tree->[1][4][$i+1][2]; $bug_fields{$tree->[1][$cur][$i]} = $tree->[1][$cur][$i+1][2];
} else { } else {
$err .= "---\n"; $err .= "---\n";
$err .= "Unknown bug field \"$tree->[1][4][$i]\""; $err .= "Unknown bug field \"$tree->[1][$cur][$i]\"";
$err .= " encountered while moving bug\n"; $err .= " encountered while moving bug\n";
$err .= "<$tree->[1][4][$i]>"; $err .= "<$tree->[1][$cur][$i]>";
if (defined $tree->[1][4][$i+1][3]) { if (defined $tree->[1][$cur][$i+1][3]) {
$err .= "\n"; $err .= "\n";
for (my $j=3 ; $j < $#{@{$tree}->[1][4][$i+1]} ; $j=$j+4) { for (my $j=3 ; $j < $#{@{$tree}->[1][$cur][$i+1]} ; $j=$j+4) {
$err .= " <". $tree->[1][4][$i+1][$j] . ">"; $err .= " <". $tree->[1][$cur][$i+1][$j] . ">";
$err .= " $tree->[1][4][$i+1][$j+1][2] "; $err .= " $tree->[1][$cur][$i+1][$j+1][2] ";
$err .= "</". $tree->[1][4][$i+1][$j] . ">\n"; $err .= "</". $tree->[1][$cur][$i+1][$j] . ">\n";
} }
} else { } else {
$err .= " $tree->[1][4][$i+1][2] "; $err .= " $tree->[1][$cur][$i+1][2] ";
}
$err .= "</$tree->[1][$cur][$i]>\n";
} }
$err .= "</$tree->[1][4][$i]>\n";
} }
}
my @long_descs; my @long_descs;
for (my $i=3 ; $i < $#{@{$tree}->[1][4]} ; $i=$i+4) { for (my $i=3 ; $i < $#{@{$tree}->[1][$cur]} ; $i=$i+4) {
if ($tree->[1][4][$i] =~ /long_desc/) { if ($tree->[1][$cur][$i] =~ /long_desc/) {
my %long_desc; my %long_desc;
$long_desc{'who'} = $tree->[1][4][$i+1][4][2]; $long_desc{'who'} = $tree->[1][$cur][$i+1][4][2];
$long_desc{'bug_when'} = $tree->[1][4][$i+1][8][2]; $long_desc{'bug_when'} = $tree->[1][$cur][$i+1][8][2];
$long_desc{'thetext'} = $tree->[1][4][$i+1][12][2]; $long_desc{'thetext'} = $tree->[1][$cur][$i+1][12][2];
push @long_descs, \%long_desc; push @long_descs, \%long_desc;
} }
} }
# instead of giving each comment its own item in the longdescs # instead of giving each comment its own item in the longdescs
# table like it should have, lets cat them all into one big # table like it should have, lets cat them all into one big
# comment otherwise we would have to lie often about who # comment otherwise we would have to lie often about who
# authored the comment since commenters in one bugzilla probably # authored the comment since commenters in one bugzilla probably
# don't have accounts in the other one. # don't have accounts in the other one.
sub by_date {my @a; my @b; $a->{'bug_when'} cmp $b->{'bug_when'}; } sub by_date {my @a; my @b; $a->{'bug_when'} cmp $b->{'bug_when'}; }
my @sorted_descs = sort by_date @long_descs; my @sorted_descs = sort by_date @long_descs;
my $long_description = ""; my $long_description = "";
for (my $i=0 ; $i < $#sorted_descs ; $i++) { for (my $z=0 ; $z <= $#sorted_descs ; $z++) {
unless ( $i==0 ) { unless ( $z==0 ) {
$long_description .= "\n\n\n------- Additional Comments From "; $long_description .= "\n\n\n------- Additional Comments From ";
$long_description .= "$sorted_descs[$i]->{'who'} "; $long_description .= "$sorted_descs[$z]->{'who'} ";
$long_description .= "$sorted_descs[$i]->{'bug_when'}"; $long_description .= "$sorted_descs[$z]->{'bug_when'}";
$long_description .= " ----\n\n"; $long_description .= " ----\n\n";
} }
$long_description .= "$sorted_descs[$i]->{'thetext'}\n" $long_description .= "$sorted_descs[$z]->{'thetext'}\n";
} }
my $comments; my $comments;
my $query = "INSERT INTO bugs (\n"; my $query = "INSERT INTO bugs (\n";
my $values = "VALUES (\n"; my $values = "VALUES (\n";
$comments .= "\n\n------- Bug Moved by $exporter "; $comments .= "\n\n------- Bug Moved by $exporter ";
$comments .= time2str("%Y-%m-%d %H:%M", time); $comments .= time2str("%Y-%m-%d %H:%M", time);
$comments .= " -------\n\n"; $comments .= " -------\n\n";
$comments .= "This bug previously known as bug $bug_fields{'bug_id'} at "; $comments .= "This bug previously known as bug $bug_fields{'bug_id'} at ";
$comments .= $urlbase . "\n"; $comments .= $urlbase . "\n";
$comments .= $urlbase . "show_bug.cgi?"; $comments .= $urlbase . "show_bug.cgi?";
$comments .= "id=" . $bug_fields{'bug_id'} . "\n"; $comments .= "id=" . $bug_fields{'bug_id'} . "\n";
$comments .= "Originally filed under the $bug_fields{'product'} "; $comments .= "Originally filed under the $bug_fields{'product'} ";
$comments .= "product and $bug_fields{'component'} component.\n"; $comments .= "product and $bug_fields{'component'} component.\n";
if (defined $bug_fields{'dependson'}) { if (defined $bug_fields{'dependson'}) {
$comments .= "Bug depends on bug(s) $bug_fields{'dependson'}.\n"; $comments .= "Bug depends on bug(s) $bug_fields{'dependson'}.\n";
} }
if (defined $bug_fields{'blocks'}) { if (defined $bug_fields{'blocks'}) {
$comments .= "Bug blocks bug(s) $bug_fields{'blocks'}.\n"; $comments .= "Bug blocks bug(s) $bug_fields{'blocks'}.\n";
} }
foreach my $field ( qw(creation_ts delta_ts keywords status_whiteboard) ) { foreach my $field ( qw(creation_ts delta_ts keywords status_whiteboard) ) {
if ( (defined $bug_fields{$field}) && ($bug_fields{$field}) ){ if ( (defined $bug_fields{$field}) && ($bug_fields{$field}) ){
$query .= "$field,\n"; $query .= "$field,\n";
$values .= SqlQuote($bug_fields{$field}) . ",\n"; $values .= SqlQuote($bug_fields{$field}) . ",\n";
} }
} }
if ( (defined $bug_fields{'short_desc'}) && ($bug_fields{'short_desc'}) ){ if ( (defined $bug_fields{'short_desc'}) && ($bug_fields{'short_desc'}) ){
$query .= "short_desc,\n"; $query .= "short_desc,\n";
$values .= SqlQuote(UnQuoteXMLChars($bug_fields{'short_desc'})) . ",\n"; $values .= SqlQuote(UnQuoteXMLChars($bug_fields{'short_desc'})) . ",\n";
} }
my @product; my @product;
if (defined ($bug_fields{'product'}) && if (defined ($bug_fields{'product'}) &&
(@product = grep /^$bug_fields{'product'}$/i, @::legal_product) ){ (@product = grep /^$bug_fields{'product'}$/i, @::legal_product) ){
$query .= "product,\n"; $query .= "product,\n";
$values .= SqlQuote($product[0]) . ",\n"; $values .= SqlQuote($product[0]) . ",\n";
} else { } else {
$query .= "product,\n"; $query .= "product,\n";
$values .= "\'Browser\',\n"; $values .= "\'Browser\',\n";
$product[0] = "Browser"; $product[0] = "Browser";
$err .= "Unknown product $bug_fields{'product'}. "; $err .= "Unknown product $bug_fields{'product'}. ";
$err .= "Moving to default product \"Browser\".\n"; $err .= "Moving to default product \"Browser\".\n";
} }
if (defined ($::versions{$product[0]} ) && if (defined ($::versions{$product[0]} ) &&
(my @version = grep /^$bug_fields{'version'}$/i, (my @version = grep /^$bug_fields{'version'}$/i,
@{$::versions{$product[0]}}) ){ @{$::versions{$product[0]}}) ){
$values .= SqlQuote($version[0]) . ",\n"; $values .= SqlQuote($version[0]) . ",\n";
$query .= "version,\n"; $query .= "version,\n";
} else { } else {
$query .= "version,\n"; $query .= "version,\n";
$values .= "\'@{$::versions{$product[0]}}->[0]\',\n"; $values .= "\'@{$::versions{$product[0]}}->[0]\',\n";
$err .= "Unknown version $bug_fields{'version'} in product $product[0]. "; $err .= "Unknown version $bug_fields{'version'} in product $product[0]. ";
$err .= "Setting version to \"@{$::versions{$product[0]}}->[0]\".\n"; $err .= "Setting version to \"@{$::versions{$product[0]}}->[0]\".\n";
} }
if (defined ($bug_fields{'priority'}) && if (defined ($bug_fields{'priority'}) &&
(my @priority = grep /^$bug_fields{'priority'}$/i, @::legal_priority) ){ (my @priority = grep /^$bug_fields{'priority'}$/i, @::legal_priority) ){
$values .= SqlQuote($priority[0]) . ",\n"; $values .= SqlQuote($priority[0]) . ",\n";
$query .= "priority,\n"; $query .= "priority,\n";
} else { } else {
$values .= "\'P3\',\n"; $values .= "\'P3\',\n";
$query .= "priority,\n"; $query .= "priority,\n";
$err .= "Unknown priority "; $err .= "Unknown priority ";
$err .= (defined $bug_fields{'priority'})?$bug_fields{'priority'}:"unknown"; $err .= (defined $bug_fields{'priority'})?$bug_fields{'priority'}:"unknown";
$err .= ". Setting to default priority \"P3\".\n"; $err .= ". Setting to default priority \"P3\".\n";
} }
if (defined ($bug_fields{'rep_platform'}) && if (defined ($bug_fields{'rep_platform'}) &&
(my @platform = grep /^$bug_fields{'rep_platform'}$/i, @::legal_platform) ){ (my @platform = grep /^$bug_fields{'rep_platform'}$/i, @::legal_platform) ){
$values .= SqlQuote($platform[0]) . ",\n"; $values .= SqlQuote($platform[0]) . ",\n";
$query .= "rep_platform,\n"; $query .= "rep_platform,\n";
} else { } else {
$values .= "\'Other\',\n"; $values .= "\'Other\',\n";
$query .= "rep_platform,\n"; $query .= "rep_platform,\n";
$err .= "Unknown platform "; $err .= "Unknown platform ";
$err .= (defined $bug_fields{'rep_platform'})? $err .= (defined $bug_fields{'rep_platform'})?
$bug_fields{'rep_platform'}:"unknown"; $bug_fields{'rep_platform'}:"unknown";
$err .= ". Setting to default platform \"Other\".\n"; $err .= ". Setting to default platform \"Other\".\n";
} }
if (defined ($bug_fields{'op_sys'}) && if (defined ($bug_fields{'op_sys'}) &&
(my @opsys = grep /^$bug_fields{'op_sys'}$/i, @::legal_opsys) ){ (my @opsys = grep /^$bug_fields{'op_sys'}$/i, @::legal_opsys) ){
$values .= SqlQuote($opsys[0]) . ",\n"; $values .= SqlQuote($opsys[0]) . ",\n";
$query .= "op_sys,\n"; $query .= "op_sys,\n";
} else { } else {
$values .= "\'other\',\n"; $values .= "\'other\',\n";
$query .= "op_sys,\n"; $query .= "op_sys,\n";
$err .= "Unknown operating system "; $err .= "Unknown operating system ";
$err .= (defined $bug_fields{'op_sys'})?$bug_fields{'op_sys'}:"unknown"; $err .= (defined $bug_fields{'op_sys'})?$bug_fields{'op_sys'}:"unknown";
$err .= ". Setting to default OS \"other\".\n"; $err .= ". Setting to default OS \"other\".\n";
} }
my @component; my @component;
if (defined ($::components{$product[0]} ) && if (defined ($::components{$product[0]} ) &&
(@component = grep /^$bug_fields{'component'}$/i, (@component = grep /^$bug_fields{'component'}$/i,
@{$::components{$product[0]}}) ){ @{$::components{$product[0]}}) ){
$values .= SqlQuote($component[0]) . ",\n"; $values .= SqlQuote($component[0]) . ",\n";
$query .= "component,\n"; $query .= "component,\n";
} else { } else {
$component[0] = $::components{$product[0]}->[0]; $component[0] = $::components{$product[0]}->[0];
$values .= SqlQuote($component[0]) . ",\n"; $values .= SqlQuote($component[0]) . ",\n";
$query .= "component,\n"; $query .= "component,\n";
...@@ -290,9 +312,9 @@ if (defined ($::components{$product[0]} ) && ...@@ -290,9 +312,9 @@ if (defined ($::components{$product[0]} ) &&
$err .= "\" in product \"$product[0]\".\n"; $err .= "\" in product \"$product[0]\".\n";
$err .= " Setting to this product\'s first component, "; $err .= " Setting to this product\'s first component, ";
$err .= "\'$::components{$product[0]}->[0]\'.\n"; $err .= "\'$::components{$product[0]}->[0]\'.\n";
} }
if (Param("usetargetmilestone")) { if (Param("usetargetmilestone")) {
if (defined ($::target_milestone{$product[0]} ) && if (defined ($::target_milestone{$product[0]} ) &&
(my @tm = grep /^$bug_fields{'target_milestone'}$/i, (my @tm = grep /^$bug_fields{'target_milestone'}$/i,
@{$::target_milestone{$product[0]}}) ){ @{$::target_milestone{$product[0]}}) ){
...@@ -311,28 +333,28 @@ if (Param("usetargetmilestone")) { ...@@ -311,28 +333,28 @@ if (Param("usetargetmilestone")) {
$err .= " Setting to default milestone for this product, "; $err .= " Setting to default milestone for this product, ";
$err .= "\'" . $tm . "\'\n"; $err .= "\'" . $tm . "\'\n";
} }
} }
if (defined ($bug_fields{'bug_severity'}) && if (defined ($bug_fields{'bug_severity'}) &&
(my @severity= grep /^$bug_fields{'bug_severity'}$/i, (my @severity= grep /^$bug_fields{'bug_severity'}$/i,
@::legal_severity) ){ @::legal_severity) ){
$values .= SqlQuote($severity[0]) . ",\n"; $values .= SqlQuote($severity[0]) . ",\n";
$query .= "bug_severity,\n"; $query .= "bug_severity,\n";
} else { } else {
$values .= "\'normal',\n"; $values .= "\'normal',\n";
$query .= "bug_severity,\n"; $query .= "bug_severity,\n";
$err .= "Unknown severity "; $err .= "Unknown severity ";
$err .= (defined $bug_fields{'bug_severity'})? $err .= (defined $bug_fields{'bug_severity'})?
$bug_fields{'bug_severity'}:"unknown"; $bug_fields{'bug_severity'}:"unknown";
$err .= ". Setting to default severity \"normal\".\n"; $err .= ". Setting to default severity \"normal\".\n";
} }
my $changed_owner = 0; my $changed_owner = 0;
if ( ($bug_fields{'assigned_to'}) && if ( ($bug_fields{'assigned_to'}) &&
( DBname_to_id($bug_fields{'assigned_to'})) ) { ( DBname_to_id($bug_fields{'assigned_to'})) ) {
$values .= "'" . DBname_to_id($bug_fields{'assigned_to'}) . "',\n"; $values .= "'" . DBname_to_id($bug_fields{'assigned_to'}) . "',\n";
$query .= "assigned_to,\n"; $query .= "assigned_to,\n";
} else { } else {
$values .= "'" . $exporterid . "',\n"; $values .= "'" . $exporterid . "',\n";
$query .= "assigned_to,\n"; $query .= "assigned_to,\n";
$changed_owner = 1; $changed_owner = 1;
...@@ -344,21 +366,21 @@ if ( ($bug_fields{'assigned_to'}) && ...@@ -344,21 +366,21 @@ if ( ($bug_fields{'assigned_to'}) &&
} else { } else {
$err .= " Previous owner is unknown.\n"; $err .= " Previous owner is unknown.\n";
} }
} }
my @resolution; my @resolution;
if (defined ($bug_fields{'resolution'}) && if (defined ($bug_fields{'resolution'}) &&
(@resolution= grep /^$bug_fields{'resolution'}$/i, @::legal_resolution) ){ (@resolution= grep /^$bug_fields{'resolution'}$/i, @::legal_resolution) ){
$values .= SqlQuote($resolution[0]) . ",\n"; $values .= SqlQuote($resolution[0]) . ",\n";
$query .= "resolution,\n"; $query .= "resolution,\n";
} elsif ( (defined $bug_fields{'resolution'}) && (!$resolution[0]) ){ } elsif ( (defined $bug_fields{'resolution'}) && (!$resolution[0]) ){
$err .= "Unknown resolution \"$bug_fields{'resolution'}\".\n"; $err .= "Unknown resolution \"$bug_fields{'resolution'}\".\n";
} }
# if the bug's owner changed, mark the bug NEW, unless a valid # if the bug's owner changed, mark the bug NEW, unless a valid
# resolution is set, which indicates that the bug should be closed. # resolution is set, which indicates that the bug should be closed.
# #
if ( ($changed_owner) && (!$resolution[0]) ) { if ( ($changed_owner) && (!$resolution[0]) ) {
$values .= "\'NEW\',\n"; $values .= "\'NEW\',\n";
$query .= "bug_status,\n"; $query .= "bug_status,\n";
$err .= "Bug assigned to new owner, setting status to \"NEW\".\n"; $err .= "Bug assigned to new owner, setting status to \"NEW\".\n";
...@@ -366,7 +388,7 @@ if ( ($changed_owner) && (!$resolution[0]) ) { ...@@ -366,7 +388,7 @@ if ( ($changed_owner) && (!$resolution[0]) ) {
$err .= (defined $bug_fields{'bug_status'})? $err .= (defined $bug_fields{'bug_status'})?
$bug_fields{'bug_status'}:"unknown"; $bug_fields{'bug_status'}:"unknown";
$err .= "\".\n"; $err .= "\".\n";
} elsif ( (defined ($bug_fields{'resolution'})) && (!$resolution[0]) ){ } elsif ( (defined ($bug_fields{'resolution'})) && (!$resolution[0]) ){
#if the resolution was illegal then set status to NEW #if the resolution was illegal then set status to NEW
$values .= "\'NEW\',\n"; $values .= "\'NEW\',\n";
$query .= "bug_status,\n"; $query .= "bug_status,\n";
...@@ -375,12 +397,12 @@ if ( ($changed_owner) && (!$resolution[0]) ) { ...@@ -375,12 +397,12 @@ if ( ($changed_owner) && (!$resolution[0]) ) {
$err .= (defined $bug_fields{'bug_status'})? $err .= (defined $bug_fields{'bug_status'})?
$bug_fields{'bug_status'}:"unknown"; $bug_fields{'bug_status'}:"unknown";
$err .= "\".\n"; $err .= "\".\n";
} elsif (defined ($bug_fields{'bug_status'}) && } elsif (defined ($bug_fields{'bug_status'}) &&
(my @status = grep /^$bug_fields{'bug_status'}$/i, @::legal_bug_status) ){ (my @status = grep /^$bug_fields{'bug_status'}$/i, @::legal_bug_status) ){
#if a bug status was set then use it, if its legal #if a bug status was set then use it, if its legal
$values .= SqlQuote($status[0]) . ",\n"; $values .= SqlQuote($status[0]) . ",\n";
$query .= "bug_status,\n"; $query .= "bug_status,\n";
} else { } else {
# if all else fails, make the bug new # if all else fails, make the bug new
$values .= "\'NEW\',\n"; $values .= "\'NEW\',\n";
$query .= "bug_status,\n"; $query .= "bug_status,\n";
...@@ -388,9 +410,9 @@ if ( ($changed_owner) && (!$resolution[0]) ) { ...@@ -388,9 +410,9 @@ if ( ($changed_owner) && (!$resolution[0]) ) {
$err .= (defined $bug_fields{'bug_status'})? $err .= (defined $bug_fields{'bug_status'})?
$bug_fields{'bug_status'}:"unknown"; $bug_fields{'bug_status'}:"unknown";
$err .= ". Setting to default status \"NEW\".\n"; $err .= ". Setting to default status \"NEW\".\n";
} }
if (Param("useqacontact")) { if (Param("useqacontact")) {
my $qa_contact; my $qa_contact;
if ( (defined $bug_fields{'qa_contact'}) && if ( (defined $bug_fields{'qa_contact'}) &&
($qa_contact = DBname_to_id($bug_fields{'qa_contact'})) ){ ($qa_contact = DBname_to_id($bug_fields{'qa_contact'})) ){
...@@ -406,28 +428,31 @@ if (Param("useqacontact")) { ...@@ -406,28 +428,31 @@ if (Param("useqacontact")) {
$err .= "Setting qa contact to the default for this product.\n"; $err .= "Setting qa contact to the default for this product.\n";
$err .= " This bug either had no qa contact or an invalid one.\n"; $err .= " This bug either had no qa contact or an invalid one.\n";
} }
} }
$query .= ") $values )\n"; $query .= ") $values )\n";
SendSQL($query); SendSQL($query);
SendSQL("select LAST_INSERT_ID()"); SendSQL("select LAST_INSERT_ID()");
my $id = FetchOneColumn(); my $id = FetchOneColumn();
foreach my $person (split(/[ ,]/, $bug_fields{'cc'})) { if (defined $bug_fields{'cc'}) {
foreach my $person (split(/[ ,]/, $bug_fields{'cc'})) {
my $uid; my $uid;
if ( ($person ne "") && ($uid = DBname_to_id($person)) ) { if ( ($person ne "") && ($uid = DBname_to_id($person)) ) {
SendSQL("insert into cc (bug_id, who) values ($id, " . SqlQuote($uid) .")"); SendSQL("insert into cc (bug_id, who) values ($id, " . SqlQuote($uid) .")");
} }
} }
}
$long_description .= "\n" . $comments; $long_description .= "\n" . $comments;
if ($err) { if ($err) {
$long_description .= "\n$err\n"; $long_description .= "\n$err\n";
} }
SendSQL("INSERT INTO longdescs (bug_id, who, bug_when, thetext) VALUES " . SendSQL("INSERT INTO longdescs (bug_id, who, bug_when, thetext) VALUES " .
"($id, $exporterid, now(), " . SqlQuote($long_description) . ")"); "($id, $exporterid, now(), " . SqlQuote($long_description) . ")");
print "Bug $bug_fields{'bug_id'}\@$urlbase "; print "Bug $bug_fields{'bug_id'}\@$urlbase ";
print "imported as bug $id.\n"; print "imported as bug $id.\n";
}
#!/usr/bonsaitools/bin/perl -w
# -*- Mode: perl; indent-tabs-mode: nil -*-
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Bugzilla Bug Tracking System.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): Dawn Endico <endico@mozilla.org>
# Terry Weissman <terry@mozilla.org>
use diagnostics;
use strict;
use Bug;
require "CGI.pl";
if (!defined $::FORM{'id'} || $::FORM{'id'} !~ /^\s*\d+(,\d+)*\s*$/) {
print "Content-type: text/html\n\n";
PutHeader("Display as XML");
print "<FORM METHOD=GET ACTION=\"xml.cgi\">\n";
print "Display bugs as XML by entering a list of bug numbers here:\n";
print "<INPUT NAME=id>\n";
print "<INPUT TYPE=\"submit\" VALUE=\"Display as XML\"><br>\n";
print " (e.g. 1000,1001,1002)\n";
print "</FORM>\n";
PutFooter();
exit;
}
quietly_check_login();
my $exporter;
if (defined $::COOKIE{"Bugzilla_login"}) {
$exporter = $::COOKIE{"Bugzilla_login"};
}
my @ids = split ( /,/, $::FORM{'id'} );
print "Content-type: text/plain\n\n";
print Bug::XML_Header( Param("urlbase"), $::param{'version'},
Param("maintainer"), $exporter );
foreach my $id (@ids) {
my $bug = new Bug($id, $::userid);
print $bug->emitXML;
$bug->bug_status("BLAH");
}
print Bug::XML_Footer;
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