From 87de9fbb8aa8aa4940cad8b2e6eb9a62bb9a401f 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: Jonathan Druart --- C4/Search.pm | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index 54b88d5d77..c448f1fd0a 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -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)) { -- 2.39.5