Commit 9da41200 authored by Simon Green's avatar Simon Green Committed by Byron Jones

Bug 879055: Add parenthesis to prevent anywordssubstr search from returning incorrect results.

r=glob, a=LpSolit
parent 5a316423
...@@ -2682,7 +2682,7 @@ sub _owner_idle_time_greater_less { ...@@ -2682,7 +2682,7 @@ sub _owner_idle_time_greater_less {
"$ld_table.who IS NULL AND $act_table.who IS NULL"; "$ld_table.who IS NULL AND $act_table.who IS NULL";
} else { } else {
$args->{term} = $args->{term} =
"$ld_table.who IS NOT NULL OR $act_table.who IS NOT NULL"; "($ld_table.who IS NOT NULL OR $act_table.who IS NOT NULL)";
} }
} }
...@@ -2926,14 +2926,14 @@ sub _anywordsubstr { ...@@ -2926,14 +2926,14 @@ sub _anywordsubstr {
my ($self, $args) = @_; my ($self, $args) = @_;
my @terms = $self->_substring_terms($args); my @terms = $self->_substring_terms($args);
$args->{term} = join("\n\tOR ", @terms); $args->{term} = '(' . join("\n\tOR ", @terms) . ')';
} }
sub _allwordssubstr { sub _allwordssubstr {
my ($self, $args) = @_; my ($self, $args) = @_;
my @terms = $self->_substring_terms($args); my @terms = $self->_substring_terms($args);
$args->{term} = join("\n\tAND ", @terms); $args->{term} = '(' . join("\n\tAND ", @terms) . ')';
} }
sub _nowordssubstr { sub _nowordssubstr {
...@@ -2945,19 +2945,19 @@ sub _nowordssubstr { ...@@ -2945,19 +2945,19 @@ sub _nowordssubstr {
sub _anywords { sub _anywords {
my ($self, $args) = @_; my ($self, $args) = @_;
my @terms = $self->_word_terms($args); my @terms = $self->_word_terms($args);
# Because _word_terms uses AND, we need to parenthesize its terms # Because _word_terms uses AND, we need to parenthesize its terms
# if there are more than one. # if there are more than one.
@terms = map("($_)", @terms) if scalar(@terms) > 1; @terms = map("($_)", @terms) if scalar(@terms) > 1;
$args->{term} = join("\n\tOR ", @terms); $args->{term} = '(' . join("\n\tOR ", @terms) . ')';
} }
sub _allwords { sub _allwords {
my ($self, $args) = @_; my ($self, $args) = @_;
my @terms = $self->_word_terms($args); my @terms = $self->_word_terms($args);
$args->{term} = join("\n\tAND ", @terms); $args->{term} = '(' . join("\n\tAND ", @terms) . ')';
} }
sub _nowords { sub _nowords {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment