]> git.donarmstrong.com Git - debbugs.git/blobdiff - Debbugs/Status.pm
pass uri_escape to templates in bugreport.cgi
[debbugs.git] / Debbugs / Status.pm
index 9723259bdf482ce4b80ffcfb81d1ffe31d54334b..4b8d82e828f06687595ea11a45164a4bb907401d 100644 (file)
@@ -49,7 +49,7 @@ use File::Copy qw(copy);
 use Encode qw(decode encode is_utf8);
 
 use Storable qw(dclone);
-use List::Util qw(min max);
+use List::AllUtils qw(min max);
 
 use Carp qw(croak);
 
@@ -282,6 +282,17 @@ sub read_bug{
     $data{archived} = (defined($location) and ($location eq 'archive'))?1:0;
     $data{bug_num} = $param{bug};
 
+    # mergedwith occasionally is sorted badly. Fix it to always be sorted by <=>
+    # and not include this bug
+    if (defined $data{mergedwith} and
+       $data{mergedwith}) {
+       $data{mergedwith} =
+           join(' ',
+                grep { $_ != $data{bug_num}}
+                sort { $a <=> $b }
+                split / /, $data{mergedwith}
+               );
+    }
     return \%data;
 }
 
@@ -307,6 +318,9 @@ my $ditch_empty_space = sub {return &{$ditch_empty}(' ',@_)};
 my %split_fields =
     (package        => \&splitpackages,
      affects        => \&splitpackages,
+     # Ideally we won't have to split source, but because some consumers of
+     # get_bug_status cannot handle arrayref, we will split it here.
+     source         => \&splitpackages,
      blocks         => $ditch_empty_space,
      blockedby      => $ditch_empty_space,
      # this isn't strictly correct, but we'll split both of them for
@@ -513,7 +527,10 @@ sub lock_read_all_merged_bugs {
            # are all merged with eachother
         # We do a cmp sort instead of an <=> sort here, because that's
         # what merge does
-           my $expectmerge= join(' ',grep {$_ != $bug } sort @bugs);
+           my $expectmerge=
+               join(' ',grep {$_ != $bug }
+                    sort { $a <=> $b }
+                    @bugs);
            if ($newdata->{mergedwith} ne $expectmerge) {
                for (1..$locks) {
                    unfilelock(exists $param{locks}?$param{locks}:());
@@ -1235,9 +1252,9 @@ sub get_bug_status {
      $status{package} = '' if not defined $status{package};
      $status{"package"} =~ s/\s*$//;
 
-     $status{source} = [binary_to_source(binary=>[split /\s*,\s*/, $status{package}],
+     $status{source} = binary_to_source(binary=>[split /\s*,\s*/, $status{package}],
                                        source_only => 1,
-                                      )];
+                                      );
 
      $status{"package"} = 'unknown' if ($status{"package"} eq '');
      $status{"severity"} = 'normal' if (not defined $status{severity} or $status{"severity"} eq '');