Skip to content

Commit b468c6e

Browse files
committed
Fixes several bugs at once related to New Charts:
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
1 parent b326ea1 commit b468c6e

3 files changed

Lines changed: 25 additions & 23 deletions

File tree

Bugzilla/Search.pm

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ use strict;
3636
package Bugzilla::Search;
3737
use base qw(Exporter);
3838
@Bugzilla::Search::EXPORT = qw(
39-
EMPTY_COLUMN
40-
4139
IsValidQueryType
4240
split_order_term
4341
translate_old_column
@@ -397,11 +395,7 @@ use constant FIELD_MAP => {
397395
long_desc => 'longdesc',
398396
};
399397

400-
# A SELECTed expression that we use as a placeholder if somebody selects
401-
# <none> for the X, Y, or Z axis in report.cgi.
402-
use constant EMPTY_COLUMN => '-1';
403-
404-
# Some fields are not sorted on themselves, but on other fields.
398+
# Some fields are not sorted on themselves, but on other fields.
405399
# We need to have a list of these fields and what they map to.
406400
use constant SPECIAL_ORDER => {
407401
'target_milestone' => {
@@ -644,7 +638,7 @@ sub REPORT_COLUMNS {
644638
# These are fields that never go into the GROUP BY on any DB. bug_id
645639
# is here because it *always* goes into the GROUP BY as the first item,
646640
# so it should be skipped when determining extra GROUP BY columns.
647-
use constant GROUP_BY_SKIP => EMPTY_COLUMN, qw(
641+
use constant GROUP_BY_SKIP => qw(
648642
bug_id
649643
flagtypes.name
650644
keywords
@@ -828,8 +822,7 @@ sub _sql_select {
828822
my $alias = $column;
829823
# Aliases cannot contain dots in them. We convert them to underscores.
830824
$alias =~ s/\./_/g;
831-
my $sql = ($column eq EMPTY_COLUMN)
832-
? EMPTY_COLUMN : COLUMNS->{$column}->{name} . " AS $alias";
825+
my $sql = COLUMNS->{$column}->{name} . " AS $alias";
833826
push(@sql_fields, $sql);
834827
}
835828
return @sql_fields;

report.cgi

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,7 @@ my $valid_columns = Bugzilla::Search::REPORT_COLUMNS;
121121
|| ($valid_columns->{$tbl_field} && trick_taint($tbl_field))
122122
|| ThrowCodeError("report_axis_invalid", {fld => "z", val => $tbl_field});
123123

124-
my @axis_fields = ($row_field || EMPTY_COLUMN,
125-
$col_field || EMPTY_COLUMN,
126-
$tbl_field || EMPTY_COLUMN);
124+
my @axis_fields = grep { $_ } ($row_field, $col_field, $tbl_field);
127125

128126
# Clone the params, so that Bugzilla::Search can modify them
129127
my $params = new Bugzilla::CGI($cgi);
@@ -154,16 +152,10 @@ my $row_isnumeric = 1;
154152
my $tbl_isnumeric = 1;
155153

156154
foreach my $result (@$results) {
157-
my ($row, $col, $tbl) = @$result;
158-
159155
# handle empty dimension member names
160-
$row = ' ' if ($row eq '');
161-
$col = ' ' if ($col eq '');
162-
$tbl = ' ' if ($tbl eq '');
163-
164-
$row = "" if ($row eq EMPTY_COLUMN);
165-
$col = "" if ($col eq EMPTY_COLUMN);
166-
$tbl = "" if ($tbl eq EMPTY_COLUMN);
156+
my $row = check_value($row_field, $result);
157+
my $col = check_value($col_field, $result);
158+
my $tbl = check_value($tbl_field, $result);
167159

168160
$data{$tbl}{$col}{$row}++;
169161
$names{"col"}{$col}++;
@@ -337,3 +329,20 @@ sub get_names {
337329

338330
return @sorted;
339331
}
332+
333+
sub check_value {
334+
my ($field, $result) = @_;
335+
336+
my $value;
337+
if (!defined $field) {
338+
$value = '';
339+
}
340+
elsif ($field eq '') {
341+
$value = ' ';
342+
}
343+
else {
344+
$value = shift @$result;
345+
$value = ' ' if (!defined $value || $value eq '');
346+
}
347+
return $value;
348+
}

template/en/default/reports/report-table.html.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ YAHOO.util.Event.addListener(window, "load", function() {
187187
[% FOREACH col = col_names %]
188188
[% row_total = row_total + data.$tbl.$col.$row %]
189189
[% NEXT IF col == "" %]
190-
[% col_totals.$col = col_totals.$col + data.$tbl.$col.$row %]
190+
[% col_totals.$col = (col_totals.$col || 0) + data.$tbl.$col.$row %]
191191

192192
[% col_idx = 1 - col_idx %]
193193
<td class="[% classes.$row_idx.$col_idx %]" align="center">

0 commit comments

Comments
 (0)