Bug 64855 - Matches relative to length
git-svn-id: svn://svn.office.custis.ru/3rdparty/bugzilla.org/trunk@901 6955db30-a419-402b-8a0d-67ecbb4d7f56master
parent
66d33dc1a9
commit
e6af0fa7e3
|
@ -69,7 +69,7 @@ sub get_param_list {
|
||||||
name => 'levenshteinusermatch',
|
name => 'levenshteinusermatch',
|
||||||
type => 't',
|
type => 't',
|
||||||
default => '0',
|
default => '0',
|
||||||
checker => \&check_numeric
|
checker => sub { $_[0] =~ /^\d+(\.\d+)?$/so ? "" : "must be a float or integer value" },
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
return @param_list;
|
return @param_list;
|
||||||
|
|
|
@ -1204,10 +1204,11 @@ sub match {
|
||||||
{
|
{
|
||||||
# CustIS Bug 64855
|
# CustIS Bug 64855
|
||||||
# try Levenshtein distance also, if enabled
|
# try Levenshtein distance also, if enabled
|
||||||
$query .= " OR levenshtein(?, login_name) < ?";
|
my $n = Bugzilla->params->{levenshteinusermatch};
|
||||||
$query .= " OR (CASE WHEN INSTR(login_name, '\@') > 0 THEN levenshtein(?, SUBSTR(login_name, 1, INSTR(login_name, '\@')-1)) ELSE 0 END) < ?";
|
$query .= " OR levenshtein(?, login_name) < ".($n < 1 ? "FLOOR(? * LENGTH(login_name))" : "?");
|
||||||
push @bind, $str, Bugzilla->params->{levenshteinusermatch};
|
$query .= " OR (CASE WHEN INSTR(login_name, '\@') > 0 THEN levenshtein(?, SUBSTR(login_name, 1, INSTR(login_name, '\@')-1)) ELSE NULL END) < ".($n < 1 ? "FLOOR(? * (INSTR(login_name, '\@')-1))" : "?");
|
||||||
push @bind, $str, Bugzilla->params->{levenshteinusermatch};
|
push @bind, $str, $n;
|
||||||
|
push @bind, $str, $n;
|
||||||
}
|
}
|
||||||
$query .= ") ";
|
$query .= ") ";
|
||||||
if (Bugzilla->params->{'usevisibilitygroups'}) {
|
if (Bugzilla->params->{'usevisibilitygroups'}) {
|
||||||
|
|
|
@ -40,11 +40,12 @@
|
||||||
emailin_autoregister => "Whether an unknown e-mail address should be converted into an " _
|
emailin_autoregister => "Whether an unknown e-mail address should be converted into an " _
|
||||||
"automatically registered disabled user account when processing incoming emails by email_in.pl",
|
"automatically registered disabled user account when processing incoming emails by email_in.pl",
|
||||||
|
|
||||||
levenshteinusermatch => "If this option is set to a non-zero value (say N), $terms.Bugzilla will " _
|
levenshteinusermatch => "If this option is set to a positive value (say N), $terms.Bugzilla will " _
|
||||||
"also offer you any user if Levenshtein distance between " _
|
"also offer you any user if Levenshtein distance between " _
|
||||||
"his login name and the entered value is less than N.<br>" _
|
"his login name and the entered value is less than N. <br>" _
|
||||||
"I.e. this option allows $terms.Bugzilla to automatically correct N-1 " _
|
"I.e. this option allows $terms.Bugzilla to automatically correct N-1 " _
|
||||||
"misprints in user fields.<br>" _
|
"misprints in user fields.<br>" _
|
||||||
|
"If N is not an integer value, it is treated relative to the length of compared string. <br>" _
|
||||||
"Levenshtein distance is calculated via MySQL User-Defined Function levenshtein(). " _
|
"Levenshtein distance is calculated via MySQL User-Defined Function levenshtein(). " _
|
||||||
"This function is not available by default and must be installed into MySQL separately.",
|
"This function is not available by default and must be installed into MySQL separately.",
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue