LibreCat / Dancer-Plugin-Catmandu-OAI

OAI-PMH provider backed by a searchable Catmandu::Store
http://librecat.org
2 stars 1 forks source link

Specifying a fix for metadata format results in runtime error #7

Closed snorri closed 8 years ago

snorri commented 8 years ago

Specifying a fix in the config:

...
       metadata_formats:
            -
                metadataPrefix: oai_dc
                ....
                fix:
                  - publication_to_dc()

results in the following error (Perl v5.22.1) when fetching a record (ListRecords, GetRecord): "Useless use of single ref constructor in void context" (Catmandu::Fix::_build_fixer).

The cause of the error seems to be that $format->{fix} is set to Catmandu::Fix object (in Dancer/Plugin/Catmandu/OAI.pm, line 111):

$format->{fix} = Catmandu::Fix->new(fixes => $fix);

It is then passed as a fix parameter to Catmandu::Exporter::Template, in line 419:

my $exporter = Catmandu::Exporter::Template->new(
  template => $format->{template},
  file => \$metadata,
  fix => $format->{fix},
);

Commenting out line 111 in Dancer/Plugin/Catmandu/OAI.pm avoids the error and the fix is executed correctly.

nics commented 8 years ago

This is an issue in Catmandu core, Catmandu->fixer($fixer) should just echo the fixer if it's already a fixer. It will be fixed in a bugfix release later today.

phochste commented 8 years ago

Fixed in the dev branch. Sending a pull request in a minute

nics commented 8 years ago

This should be fixed in Catmandu core. Creating a new Fix object every time is not efficient.

nics commented 8 years ago

fixed in 0.0308