Skip to content

Commit

Permalink
Better fix for plk/biblatex#1297 with correct regression
Browse files Browse the repository at this point in the history
  • Loading branch information
plk committed Sep 9, 2023
1 parent c145138 commit cf5c5c0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
22 changes: 15 additions & 7 deletions lib/Biber.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3111,16 +3111,10 @@ sub process_lists {
# Filtering - must come before sorting/labelling so that there are no gaps in e.g. extradate
if (my $filters = $list->get_filters) {
my $flist = [];
my @sets = grep {$section->bibentry($_)->get_field('entrytype') eq 'set'} $list->get_keys->@*;

KEYLOOP: foreach my $k ($list->get_keys->@*) {
my $be = $section->bibentry($k);

# Entries that are in a set which is in this list should not be filtered out
if (first {$be->get_field('entryset')} @sets) {
push $flist->@*, $k;
next KEYLOOP
}

foreach my $f ($filters->@*) {
# Filter disjunction is ok if any of the checks are ok, hence the grep()
if (ref $f eq 'ARRAY') {
Expand All @@ -3130,8 +3124,22 @@ sub process_lists {
next KEYLOOP unless check_list_filter($k, $f->{type}, $f->{value}, $be);
}
}

push $flist->@*, $k;
}

# Now add set members of sets which have not been filtered out
my @sets = grep {$section->bibentry($_)->get_field('entrytype') eq 'set'} $flist->@*;
foreach my $k ($list->get_keys->@*) {
my $be = $section->bibentry($k);
if (first {$be->get_field('entryset')} @sets) {
push $flist->@*, $k;
}
}

# $flist now has the filtered list keys, possibly with duplicates due to sets so uniqify
$flist->@* = uniq $flist->@*;

if ($logger->is_debug()) { # performance tune
$logger->debug("Keys after filtering list '$lname' in section $secnum: " . join(', ', $flist->@*));
}
Expand Down
3 changes: 2 additions & 1 deletion t/set-static.t
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ my $string1 = q| \entry{Static1}{set}{}{}
\field{sortinit}{B}
\field{sortinithash}{d7095fff47cda75ca2589920aae98399}
\field{annotation}{Some notes}
\field{shorthand}{STAT1}
\endentry
|;

Expand Down Expand Up @@ -179,4 +180,4 @@ is_deeply($biber->datalists->get_lists_by_attrs(section => 0,
labelprefix => '',
uniquenametemplatename => 'global',
labelalphanametemplatename => 'global',
namehashtemplatename => 'global')->[0]->get_keys, ['Static2', 'Static1', 'Static3', 'Static4'], 'Shorthand - sets');
namehashtemplatename => 'global')->[0]->get_keys, ['Static2', 'Static3', 'Static4', 'Static1'], 'Shorthand - sets');
1 change: 1 addition & 0 deletions t/tdata/sets.bib
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ @ARTICLE{Elias1955b

@SET{Static1,
ENTRYSET = {Static2alias, Static3, Static4, missing1},
SHORTHAND = {STAT1},
ANNOTATION = {Some notes}
}

Expand Down

0 comments on commit cf5c5c0

Please sign in to comment.