]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Fixes several bugs at once related to New Charts:
authorFrédéric Buclin <LpSolit@gmail.com>
Sat, 11 Jun 2011 10:42:50 +0000 (12:42 +0200)
committerFrédéric Buclin <LpSolit@gmail.com>
Sat, 11 Jun 2011 10:42:50 +0000 (12:42 +0200)
Bug 610739: YUI-generated tabular reports do not work if only one axis is set
Bug 617676: Wrong URLs in the "Total" row at the bottom of tabular reports when JS is enabled
Bug 655848: Use of uninitialized value $tbl in string eq at /var/www/html/bugzilla/report.cgi line 162
r/a=LpSolit

Bugzilla/Search.pm
report.cgi
template/en/default/reports/report-table.html.tmpl

index 5c9d37d9a0bcb4245bf23b5937643e34049dec5a..3ec5394b9fee72414c3d1080cf3898331ad3ac14 100644 (file)
@@ -36,8 +36,6 @@ use strict;
 package Bugzilla::Search;
 use base qw(Exporter);
 @Bugzilla::Search::EXPORT = qw(
-    EMPTY_COLUMN
-
     IsValidQueryType
     split_order_term
     translate_old_column
@@ -397,11 +395,7 @@ use constant FIELD_MAP => {
     long_desc => 'longdesc',
 };
 
-# A SELECTed expression that we use as a placeholder if somebody selects
-# <none> for the X, Y, or Z axis in report.cgi.
-use constant EMPTY_COLUMN => '-1';
-
-# Some fields are not sorted on themselves, but on other fields. 
+# Some fields are not sorted on themselves, but on other fields.
 # We need to have a list of these fields and what they map to.
 use constant SPECIAL_ORDER => {
     'target_milestone' => {
@@ -644,7 +638,7 @@ sub REPORT_COLUMNS {
 # These are fields that never go into the GROUP BY on any DB. bug_id
 # is here because it *always* goes into the GROUP BY as the first item,
 # so it should be skipped when determining extra GROUP BY columns.
-use constant GROUP_BY_SKIP => EMPTY_COLUMN, qw(
+use constant GROUP_BY_SKIP => qw(
     bug_id
     flagtypes.name
     keywords
@@ -828,8 +822,7 @@ sub _sql_select {
         my $alias = $column;
         # Aliases cannot contain dots in them. We convert them to underscores.
         $alias =~ s/\./_/g;
-        my $sql = ($column eq EMPTY_COLUMN)
-                  ? EMPTY_COLUMN : COLUMNS->{$column}->{name} . " AS $alias";
+        my $sql = COLUMNS->{$column}->{name} . " AS $alias";
         push(@sql_fields, $sql);
     }
     return @sql_fields;
index 8d80b192fb078e7564395109af6d64d68c08426f..a71776bfe6a1eac41f8e01e4bc8a8a279cdf8a9b 100755 (executable)
@@ -121,9 +121,7 @@ my $valid_columns = Bugzilla::Search::REPORT_COLUMNS;
   || ($valid_columns->{$tbl_field} && trick_taint($tbl_field))
   || ThrowCodeError("report_axis_invalid", {fld => "z", val => $tbl_field});
 
-my @axis_fields = ($row_field || EMPTY_COLUMN, 
-                   $col_field || EMPTY_COLUMN,
-                   $tbl_field || EMPTY_COLUMN);
+my @axis_fields = grep { $_ } ($row_field, $col_field, $tbl_field);
 
 # Clone the params, so that Bugzilla::Search can modify them
 my $params = new Bugzilla::CGI($cgi);
@@ -154,16 +152,10 @@ my $row_isnumeric = 1;
 my $tbl_isnumeric = 1;
 
 foreach my $result (@$results) {
-    my ($row, $col, $tbl) = @$result;
-
     # handle empty dimension member names
-    $row = ' ' if ($row eq '');
-    $col = ' ' if ($col eq '');
-    $tbl = ' ' if ($tbl eq '');
-
-    $row = "" if ($row eq EMPTY_COLUMN);
-    $col = "" if ($col eq EMPTY_COLUMN);
-    $tbl = "" if ($tbl eq EMPTY_COLUMN);
+    my $row = check_value($row_field, $result);
+    my $col = check_value($col_field, $result);
+    my $tbl = check_value($tbl_field, $result);
 
     $data{$tbl}{$col}{$row}++;
     $names{"col"}{$col}++;
@@ -337,3 +329,20 @@ sub get_names {
     
     return @sorted;
 }
+
+sub check_value {
+    my ($field, $result) = @_;
+
+    my $value;
+    if (!defined $field) {
+        $value = '';
+    }
+    elsif ($field eq '') {
+        $value = ' ';
+    }
+    else {
+        $value = shift @$result;
+        $value = ' ' if (!defined $value || $value eq '');
+    }
+    return $value;
+}
index cd854230f4d5f1edb857d6f279346de8e63a7c39..f1418e6a99a927611f09758f4e44b5352c260196 100644 (file)
@@ -187,7 +187,7 @@ YAHOO.util.Event.addListener(window, "load", function() {
       [% FOREACH col = col_names %]
         [% row_total = row_total + data.$tbl.$col.$row %]
         [% NEXT IF col == "" %]
-        [% col_totals.$col = col_totals.$col + data.$tbl.$col.$row %]
+        [% col_totals.$col = (col_totals.$col || 0) + data.$tbl.$col.$row %]
         
         [% col_idx = 1 - col_idx %]
         <td class="[% classes.$row_idx.$col_idx %]" align="center">