RSS

trunk : 6088

lpsolit%gmail.com
2008-06-13 21:44:00
Revision ID: cvs-1:lpsolitgmail.com-20080614024400-s4u1lrai8z05ihz6
Bug 439075: Importing bugs which have a multi-select field with a single value fails - Patch by Frédéric Buclin <LpSolit@gmail.com> r=ghendricks a=LpSolit

collapse all collapse all

added added

removed removed

281
    return $err;
281
    return $err;
282
}
282
}
283
 
283
 
 
 
284
# Converts and returns the input data as an array.
 
 
285
sub _to_array {
 
 
286
    my $value = shift;
 
 
287
 
 
 
288
    $value = [$value] if !ref($value);
 
 
289
    return @$value;
 
 
290
}
 
 
291
 
284
###############################################################################
292
###############################################################################
285
# XML Handlers                                                                #
293
# XML Handlers                                                                #
286
###############################################################################
294
###############################################################################
565
    $comments .= $urlbase . "show_bug.cgi?id=" . $bug_fields{'bug_id'} . "\n";
573
    $comments .= $urlbase . "show_bug.cgi?id=" . $bug_fields{'bug_id'} . "\n";
566
    if ( defined $bug_fields{'dependson'} ) {
574
    if ( defined $bug_fields{'dependson'} ) {
567
        $comments .= "This bug depended on bug(s) " .
575
        $comments .= "This bug depended on bug(s) " .
568
                     join(' ', @{$bug_fields{'dependson'}}) . ".\n";
576
                     join(' ', _to_array($bug_fields{'dependson'})) . ".\n";
569
    }
577
    }
570
    if ( defined $bug_fields{'blocked'} ) {
578
    if ( defined $bug_fields{'blocked'} ) {
571
        $comments .= "This bug blocked bug(s) " .
579
        $comments .= "This bug blocked bug(s) " .
572
                     join(' ', @{$bug_fields{'blocked'}}) . ".\n";
580
                     join(' ', _to_array($bug_fields{'blocked'})) . ".\n";
573
    }
581
    }
574
 
582
 
575
    # Now we process each of the fields in turn and make sure they contain
583
    # Now we process each of the fields in turn and make sure they contain
1057
            }
1065
            }
1058
        } elsif ($field->type == FIELD_TYPE_MULTI_SELECT) {
1066
        } elsif ($field->type == FIELD_TYPE_MULTI_SELECT) {
1059
            my @legal_values;
1067
            my @legal_values;
1060
            foreach my $item (@$value) {
1068
            foreach my $item (_to_array($value)) {
1061
                my $is_well_formed = check_field($custom_field, $item, undef, ERR_LEVEL);
1069
                my $is_well_formed = check_field($custom_field, $item, undef, ERR_LEVEL);
1062
                if ($is_well_formed) {
1070
                if ($is_well_formed) {
1063
                    push(@legal_values, $item);
1071
                    push(@legal_values, $item);
1116
    if ( defined $bug_fields{'cc'} ) {
1124
    if ( defined $bug_fields{'cc'} ) {
1117
        my %ccseen;
1125
        my %ccseen;
1118
        my $sth_cc = $dbh->prepare("INSERT INTO cc (bug_id, who) VALUES (?,?)");
1126
        my $sth_cc = $dbh->prepare("INSERT INTO cc (bug_id, who) VALUES (?,?)");
1119
        foreach my $person (@{$bug_fields{'cc'}}) {
1127
        foreach my $person (_to_array($bug_fields{'cc'})) {
1120
            next unless $person;
1128
            next unless $person;
1121
            my $uid;
1129
            my $uid;
1122
            if ($uid = login_to_id($person)) {
1130
            if ($uid = login_to_id($person)) {

Loggerhead runs on Bazaar branches