Open hrvoj3e opened 6 months ago
There is a workaround if you force PCRE tag matching.
// fetch all fields works OK
$foundFields = $record->getFields('.*', pcre: true);
// same fix MUST be used when fetching all subfields
$fieldUsed->getSubfields('.*', pcre: true);
Scriptotek\Marc\Record::getFields()
has a bug as it has in docs @return \Scriptotek\Marc\Fields\Field[] An array of wrapped fields.
but that is not true and it throws fatal error.
This works because using PCRE it will return an array (it uses File_MARC_Record::getFields()
) which Scriptotek\Marc\Record::getFields()
expects
function getFields($spec = null, $pcre = null)
{
if (!$spec) {
return $this->fields; // <-------- THIS IS PROBLEMATIC as it returns \File_MARC_List
}
// Okay, we're actually looking for something specific
$matches = array();
foreach ($this->fields as $field) {
if (($pcre && preg_match("/$spec/", $field->getTag()))
|| (!$pcre && $spec == $field->getTag())
) {
$matches[] = $field;
}
}
return $matches;
}
I tried manually using
"pear/file_marc": "master@dev"
but it has not helped