Skip to content

Commit 60c3e64

Browse files
Alexander MerkleDave Miller
Alexander Merkle
authored and
Dave Miller
committed
Bug 1217882: ensure SQL querys from FlagTypeComment are valid
when $types is empty the SQL query is invalid
1 parent 17a8057 commit 60c3e64

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

extensions/FlagTypeComment/Extension.pm

+8-6
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ sub _set_ftc_states {
7272
my $dbh = Bugzilla->dbh;
7373

7474
my $ftc_flags;
75-
my $db_result;
75+
my $db_result = [];
7676
if ($file =~ /^admin\//) {
7777

7878
# admin
@@ -121,11 +121,13 @@ sub _set_ftc_states {
121121

122122
my $types = join(',', map { $_->id } @$flag_types);
123123
my $states = "'" . join("','", FLAGTYPE_COMMENT_STATES) . "'";
124-
$db_result = $dbh->selectall_arrayref(
125-
"SELECT type_id AS flagtype, on_status AS state, comment AS text
126-
FROM flagtype_comments
127-
WHERE type_id IN ($types) AND on_status IN ($states)", {Slice => {}}
128-
);
124+
if ($types) {
125+
$db_result = $dbh->selectall_arrayref(
126+
"SELECT type_id AS flagtype, on_status AS state, comment AS text
127+
FROM flagtype_comments
128+
WHERE type_id IN ($types) AND on_status IN ($states)", {Slice => {}}
129+
);
130+
}
129131
}
130132

131133
foreach my $row (@$db_result) {

0 commit comments

Comments
 (0)