]> git.donarmstrong.com Git - debbugs.git/blobdiff - Debbugs/Status.pm
fix incorrect lexical variables in Debbugs
[debbugs.git] / Debbugs / Status.pm
index a7bce9de712c3d985be65bfad84bd7f1a8f16584..0cc0af9a59a4ad743af6b8951f4a66074a1689d4 100644 (file)
@@ -28,7 +28,7 @@ use vars qw($VERSION $DEBUG %EXPORT_TAGS @EXPORT_OK @EXPORT);
 use base qw(Exporter);
 
 use Params::Validate qw(validate_with :types);
-use Debbugs::Common qw(:util :lock :quit);
+use Debbugs::Common qw(:util :lock :quit :misc);
 use Debbugs::Config qw(:config);
 use Debbugs::MIME qw(decode_rfc1522 encode_rfc1522);
 use Debbugs::Packages qw(makesourceversions getversions binarytosource);
@@ -48,7 +48,7 @@ BEGIN{
                     read   => [qw(readbug read_bug lockreadbug)],
                     write  => [qw(writebug makestatus unlockwritebug)],
                     versions => [qw(addfoundversions addfixedversions),
-                                 qw(removefoundversions)
+                                 qw(removefoundversions removefixedversions)
                                 ],
                     hook     => [qw(bughook bughook_archive)],
                    );
@@ -132,7 +132,10 @@ sub read_bug{
     my %param = validate_with(params => \@_,
                              spec   => {bug => {type => SCALAR,
                                                 optional => 1,
-                                                regex    => qr/^\d+/,
+                                                # something really
+                                                # stupid passes
+                                                # negative bugnumbers
+                                                regex    => qr/^-?\d+/,
                                                },
                                         location => {type => SCALAR|UNDEF,
                                                      optional => 1,
@@ -440,7 +443,7 @@ sub addfixedversions {
     my $version = shift;
     my $isbinary = shift;
     return unless defined $version;
-    undef $package if $package =~ m[(?:\s|/)];
+    undef $package if defined $package and $package =~ m[(?:\s|/)];
     my $source = $package;
 
     if (defined $package and $isbinary) {
@@ -543,7 +546,7 @@ Returns undef on failure.
 =cut
 
 # This will eventually need to be fixed before we start using mod_perl
-my $version_cache = {};
+our $version_cache = {};
 sub bug_archiveable{
      my %param = validate_with(params => \@_,
                               spec   => {bug => {type => SCALAR,
@@ -647,11 +650,11 @@ sub bug_archiveable{
 =item bug_index -- optional tied index of bug status infomration;
 currently not correctly implemented.
 
-=item version -- optional version to check package status at
+=item version -- optional version(s) to check package status at
 
-=item dist -- optional distribution to check package status at
+=item dist -- optional distribution(s) to check package status at
 
-=item arch -- optional architecture to check package status at
+=item arch -- optional architecture(s) to check package status at
 
 =item usertags -- optional hashref of usertags
 
@@ -680,13 +683,13 @@ sub get_bug_status {
                                          bug_index => {type => OBJECT,
                                                        optional => 1,
                                                       },
-                                         version   => {type => SCALAR,
+                                         version   => {type => SCALAR|ARRAYREF,
                                                        optional => 1,
                                                       },
-                                         dist       => {type => SCALAR,
+                                         dist       => {type => SCALAR|ARRAYREF,
                                                         optional => 1,
                                                        },
-                                         arch       => {type => SCALAR,
+                                         arch       => {type => SCALAR|ARRAYREF,
                                                         optional => 1,
                                                        },
                                          usertags   => {type => HASHREF,
@@ -734,7 +737,7 @@ sub get_bug_status {
      $status{"pending"} = 'fixed'          if ($tags{fixed});
 
 
-     my $presence = bug_presence(map{exists $param{$_}?($_,$param{$_}):()}
+     my $presence = bug_presence(map{(exists $param{$_})?($_,$param{$_}):()}
                                 qw(bug sourceversions arch dist version found fixed package)
                                );
      if (defined $presence) {
@@ -793,13 +796,13 @@ sub bug_presence {
                                          status    => {type => HASHREF,
                                                        optional => 1,
                                                       },
-                                         version   => {type => SCALAR,
+                                         version   => {type => SCALAR|ARRAYREF,
                                                        optional => 1,
                                                       },
-                                         dist       => {type => SCALAR,
+                                         dist       => {type => SCALAR|ARRAYREF,
                                                         optional => 1,
                                                        },
-                                         arch       => {type => SCALAR,
+                                         arch       => {type => SCALAR|ARRAYREF,
                                                         optional => 1,
                                                        },
                                          sourceversions => {type => ARRAYREF,
@@ -819,37 +822,54 @@ sub bug_presence {
 
      my @sourceversions;
      if (not exists $param{sourceversions}) {
-         my @versions;
+         my %sourceversions;
          if (defined $param{version}) {
-              @versions = ($param{version});
+              foreach my $arch (make_list($param{arch})) {
+                   my @temp = makesourceversions($status{package},
+                                                 $arch,
+                                                 make_list($param{version})
+                                                );
+                   @sourceversions{@temp} = (1) x @temp;
+              }
          } elsif (defined $param{dist}) {
-              @versions = getversions($status{package}, $param{dist}, $param{arch});
+              foreach my $arch (make_list($param{arch})) {
+                   my @versions;
+                   foreach my $dist (make_list($param{dist})) {
+                        push @versions, getversions($status{package}, $dist, $arch);
+                   }
+                   my @temp = makesourceversions($status{package},
+                                                 $arch,
+                                                 @versions
+                                                );
+                   @sourceversions{@temp} = (1) x @temp;
+              }
          }
 
          # TODO: This should probably be handled further out for efficiency and
          # for more ease of distinguishing between pkg= and src= queries.
-         @sourceversions = makesourceversions($status{package},
-                                              $param{arch},
-                                              @versions);
+         @sourceversions = keys %sourceversions;
      }
      else {
          @sourceversions = @{$param{sourceversions}};
      }
+     my $maxbuggy = 'undef';
      if (@sourceversions) {
-         my $maxbuggy = max_buggy(bug => $param{bug},
+         $maxbuggy = max_buggy(bug => $param{bug},
                                   sourceversions => \@sourceversions,
                                   found => $status{found_versions},
                                   fixed => $status{fixed_versions},
                                   package => $status{package},
                                   version_cache => $version_cache,
                                  );
-         return $maxbuggy;
+     }
+     elsif (defined $param{dist}) {
+         return 'absent';
      }
      if (length($status{done}) and
         (not @sourceversions or not @{$status{fixed_versions}})) {
          return 'fixed';
      }
-     return undef;
+     return $maxbuggy;
 }