[Koha-bugs] [Bug 19575] Use canonical field names and resolve aliased fields

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Mon Jan 15 18:51:19 CET 2018


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

--- Comment #32 from David Gustafsson <glasklas at gmail.com> ---
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.


More information about the Koha-bugs mailing list