diff --git a/Bugzilla/DB/Mysql.pm b/Bugzilla/DB/Mysql.pm index bb3ccfb88..f00e530e0 100644 --- a/Bugzilla/DB/Mysql.pm +++ b/Bugzilla/DB/Mysql.pm @@ -179,8 +179,7 @@ sub sql_fulltext_search my ($self, $column, $text) = @_; # stem text - my $lang = LANG_FULL_ISO->{lc(Bugzilla->params->{stem_language}||'')} || 'en'; - $text = stem_text($text, $lang); + $text = stem_text($text, Bugzilla->params->{stem_language}); # quote un-quoted compound words my @words = quotewords('[\s()]+', 'delimiters', $text); diff --git a/Bugzilla/DB/Pg.pm b/Bugzilla/DB/Pg.pm index db4d0b9e3..55474f7e7 100644 --- a/Bugzilla/DB/Pg.pm +++ b/Bugzilla/DB/Pg.pm @@ -44,7 +44,7 @@ package Bugzilla::DB::Pg; use strict; use Bugzilla::Error; -use Bugzilla::Constants qw(LANG_ISO_FULL); +use Bugzilla::Constants qw(LANG_ISO_FULL LANG_FULL_ISO); use DBD::Pg; # This module extends the DB interface via inheritance @@ -189,13 +189,15 @@ sub sql_fulltext_search my $self = shift; my ($column, $text) = @_; $text = $self->quote($text); + my $lang = lc(Bugzilla->params->{stem_language} || 'en'); + $lang = LANG_ISO_FULL->{$lang} || 'english' if !LANG_FULL_ISO->{$lang}; # Try to_tsquery, and use plainto_tsquery if the syntax is incorrect # FIXME reporting query parse errors to user would be useful here - eval { $self->do("SELECT to_tsquery($language$text)") }; + eval { $self->do("SELECT to_tsquery('$lang',$text)") }; my $op = $@ ? 'plainto_tsquery' : 'to_tsquery'; return ( - "($column \@\@ $op($language$text))", - "(ts_rank($column, $op($language$text)))", + "($column \@\@ $op('$lang',$text))", + "(ts_rank($column, $op('$lang',$text)))", ); } @@ -204,7 +206,8 @@ sub quote_fulltext { my $self = shift; my ($a) = @_; - my $lang = LANG_ISO_FULL->{Bugzilla->params->{stem_language}} || 'english'; + my $lang = lc(Bugzilla->params->{stem_language}||'en'); + $lang = LANG_ISO_FULL->{$lang} || 'english' if !LANG_FULL_ISO->{$lang}; return "to_tsvector('$lang',".$self->quote($a).")"; } diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm index a0e8ae880..94661d1e4 100644 --- a/Bugzilla/Util.pm +++ b/Bugzilla/Util.pm @@ -740,6 +740,7 @@ sub stem_text my ($text, $lang, $allow_verbatim) = @_; return '' if !defined $text || $text =~ /^\s*$/so; return $text if !$INC{'Lingua/Stem/Snowball.pm'}; + $lang = lc($lang || 'en'); $lang = LANG_FULL_ISO->{$lang} || 'en' if !LANG_ISO_FULL->{$lang}; Encode::_utf8_on($text) if Bugzilla->params->{utf8}; # CustIS Bug 66033 - _ is wanted to also be a delimiter