Bug 28847: Remove dead code and make regex consistent

This updates the regex code to match throughout the routine and removes
code that would no longer be reached.

Note that the code to update library name in the query descruiption was
broken before this patch, so removal does not change behaviour

Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Nick Clemens 2021-09-13 11:53:39 +00:00 committed by Jonathan Druart
parent c4955c6924
commit 87de9fbb8a

View file

@ -1472,12 +1472,12 @@ sub buildQuery {
$limit_cgi .= "&limit=" . uri_escape_utf8($this_limit);
$limit_desc .= " $this_limit";
}
elsif ( $this_limit =~ 'multibranchlimit|^branch' ) {
elsif ( $this_limit =~ '^multibranchlimit:|^branch:' ) {
$limit_cgi .= "&limit=" . uri_escape_utf8($this_limit);
$limit .= " and " if $limit || $query;
my $branchfield = C4::Context->preference('SearchLimitLibrary');
my @branchcodes;
if( $this_limit =~ 'multibranchlimit' ){
if( $this_limit =~ '^multibranchlimit:' ){
my ($group_id) = ( $this_limit =~ /^multibranchlimit:(.*)$/ );
my $search_group = Koha::Library::Groups->find( $group_id );
@branchcodes = map { $_->branchcode } $search_group->all_libraries;
@ -1508,17 +1508,7 @@ sub buildQuery {
$limit .= " and " if $limit || $query;
$limit .= "$this_limit";
$limit_cgi .= "&limit=" . uri_escape_utf8($this_limit);
if ($this_limit =~ /^branch:(.+)/) {
my $branchcode = $1;
my $library = Koha::Libraries->find( $branchcode );
if (defined $library) {
$limit_desc .= " branch:" . $library->branchname;
} else {
$limit_desc .= " $this_limit";
}
} else {
$limit_desc .= " $this_limit";
}
$limit_desc .= " $this_limit";
}
}
foreach my $k (keys (%group_OR_limits)) {