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).
# 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) {
# 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});