From 83328705b207ba7691f8b1859a2b3c6a11c1b34b Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 13 Sep 2021 11:53:39 +0000 Subject: [PATCH] Bug 28847: Remove dead code and make regex consistent MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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ä Signed-off-by: Kyle M Hall --- C4/Search.pm | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index ee5b623e36..548c6fdcf3 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -1474,12 +1474,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; @@ -1510,17 +1510,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)) { -- 2.39.5