From a0a885fe5e7e4d1da89cf1da54df7feaac7cf524 Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Mon, 17 Sep 2018 11:33:29 -0400 Subject: [PATCH] LP#1781480: Closures remeber values in subtle ways... ... and we must take care to avoid that. This commit forces a state variable to be statically assigned an empty list rather than depending on the idiomatic undef to vivicate an empty list. This is important for all OpenSRF methods, and manifests here as a search "remembering" a previously chosen location group. A comment to that point is included for our future selves. The core probably arises from the fact that, in the end, OpenSRF methods are generated closures. Signed-off-by: Mike Rylander Signed-off-by: Jeanette Lundgren Signed-off-by: Jason Stephenson --- .../Application/Storage/Publisher/metabib.pm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/metabib.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/metabib.pm index 506846a5c2..828304f407 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/metabib.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/metabib.pm @@ -451,7 +451,9 @@ sub biblio_multi_search_full_rec { my $cl_table = asset::copy_location->table; my $br_table = biblio::record_entry->table; - my $cj = 'HAVING COUNT(x.record) = ' . scalar(@selects) if ($class_join eq 'AND'); + my $cj = undef; + $cj = 'HAVING COUNT(x.record) = ' . scalar(@selects) if ($class_join eq 'AND'); + my $search_table = '(SELECT x.record, sum(x.sum) FROM (('. join(') UNION ALL (', @selects). @@ -3057,7 +3059,8 @@ sub query_parser_fts { # gather location_groups if (my ($filter) = $query->parse_tree->find_filter('location_groups')) { - my @loc_groups = @{$filter->args} if (@{$filter->args}); + my @loc_groups = (); + @loc_groups = @{$filter->args} if (@{$filter->args}); # collect the mapped locations and add them to the locations() filter if (@loc_groups) { @@ -3227,7 +3230,11 @@ sub query_parser_fts_wrapper { # explicitly supplied one my $site = undef; - my @lg_id_list = @{$args{location_groups}} if (ref $args{location_groups}); + my @lg_id_list = (); # We must define the variable with a static value + # because an idomatic my+set causes the previous + # value is remembered via closure. + + @lg_id_list = @{$args{location_groups}} if (ref $args{location_groups}); my ($lg_filter) = $base_plan->parse_tree->find_filter('location_groups'); @lg_id_list = @{$lg_filter->args} if ($lg_filter && @{$lg_filter->args}); -- 2.43.2