[Koha-bugs] [Bug 24531] OAI-PMH sets only consider first field with a given tag

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Wed Jan 29 15:38:46 CET 2020


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24531

--- Comment #1 from Magnus Enger <magnus at libriotech.no> ---
A mapping to say that a record should be included in a OAI-PMH set if it has
the value "PDF" in field 347$b can be defined as:

Field = 347
Subfield = b
Operator = equals
Value = PDF

In C4::OAI::Sets::_evalRule, this is the code that picks out the relevant field
and subfield: 

 544     my @subfield_values = $record->subfield($field, $subfield);

But this will only return the value from the first field with tag $field, it
does not really work in array context. The code works, if your 347$b = PDF
occurs as the first 347 field, but not if it occurs in a subsequent field 347. 

So the code needs to be expanded into something like this:

my @subfield_values;
my @fields = $record->field($field);
foreach my $field ( @fields ) {
    if ( my $subfield_value = $field->subfield($subfield) ) {
        push @subfield_values, $subfield_value;
    }
}

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.


More information about the Koha-bugs mailing list