https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19575

--- Comment #32 from David Gustafsson <[email protected]> ---
Case insensitive field names in searches is now fixed. A few changes I made
could use some extra motivation/explanation:

# sub _convert_index_strings_freeform() (line 685):
changed from:
sub _convert_index_strings_freeform {
    my ( $self, $search ) = @_;
    while ( my ( $zeb, $es ) = each %index_field_convert ) {
        $search =~ s/\b$zeb(?:,[\w\-]*)?:/$es:/g;
    }
    return $search;
}
to:
my $field_name_pattern = '[\w\-]+';
my $multi_field_pattern = "(?:\\.$field_name_pattern)*";
...
sub _convert_index_strings_freeform {
    my ( $self, $search ) = @_;
    $search =~
s/($field_name_pattern)(?:,[\w-]*)?($multi_field_pattern):/\L$1\E$2:/og;
    $search =~ s/($field_name_pattern)($multi_field_pattern):/(exists
$index_field_convert{$1} ? $index_field_convert{$1} : $1)."$2:"/oge;
    return $search;
}
(Excluding comments)
With new regexps for lower-casing field names etc there is a lot of duplication
for things like field names, possible multiple/subfields etc, so created some
variables for components that are often reused to prevent some pitfalls in
possible future refactoring. I'm not sure it really matters performance wise,
but also replaced the alias replacement code with a more efficient code since
the %index_field_convert hash is now much larger than before.

Also, the regexp in sub _truncate_terms() has been changed to also use
$field_name_pattern and $multi_field_pattern.

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list
[email protected]
http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to