Bug 24531: Fix OAI-PMH sets for records with repeated fields
Currently, an OAI-PMH set mapping will only match if the value it is looking for occurs in the first instance of a repeated field. To test: - Apply the first patch with two new tests - Run something like this: sudo koha-shell -c "prove -v t/db_dependent/OAI/Sets.t" kohadev - Verify that the last test fails - Apply this secind patch - Rerun the test file above - Verify that all tests now pass Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Josef Moravec <josef.moravec@gmail.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
parent
3a49e02a5d
commit
d1a0921fd1
1 changed files with 14 additions and 3 deletions
|
@ -541,14 +541,25 @@ sub _evalRule {
|
||||||
my $subfield = $mapping->{'marcsubfield'};
|
my $subfield = $mapping->{'marcsubfield'};
|
||||||
my $operator = $mapping->{'operator'};
|
my $operator = $mapping->{'operator'};
|
||||||
my $value = $mapping->{'marcvalue'};
|
my $value = $mapping->{'marcvalue'};
|
||||||
my @subfield_values = $record->subfield($field, $subfield);
|
|
||||||
|
my @all_subfield_values;
|
||||||
|
# Get all the fields with the given tag
|
||||||
|
my @fields = $record->field($field);
|
||||||
|
# Iterate over all the fields
|
||||||
|
foreach my $field ( @fields ) {
|
||||||
|
# Get the values from all the subfields with the given subfield code
|
||||||
|
if ( my @subfield_values = $field->subfield($subfield) ) {
|
||||||
|
push @all_subfield_values, @subfield_values;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($operator eq 'notequal') {
|
if ($operator eq 'notequal') {
|
||||||
if(0 == grep /^$value$/, @subfield_values) {
|
if(0 == grep /^$value$/, @all_subfield_values) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(0 < grep /^$value$/, @subfield_values) {
|
if(0 < grep /^$value$/, @all_subfield_values) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue