The following errors appear when trying to use unapi under Plack (among
others):
Variable "$cgi" is not available at /home/jcamins/kohaclone/opac/unapi line 160.
Variable "$format_to_stylesheet_map" is not available at /home/jcamins/kohaclone/opac/unapi line 173.
Variable "$format_info" is not available at /home/jcamins/kohaclone/opac/unapi line 174.
Variable "$format_to_stylesheet_map" is not available at /home/jcamins/kohaclone/opac/unapi line 185.
To test:
1) Try to view /cgi-bin/koha/unapi under Plack
2) There is no step 2. Plack crashes.
3) Apply patch.
4) Try to view /cgi-bin/koha/unapi again, and note that it doesn't crash
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
I'm puzzled how this ever worked anyway, accidentally i'm guessing,
this tidies up some lazy coding
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
my $format = $cgi->param('format');
if (not defined $format) {
my $format = $cgi->param('format');
if (not defined $format) {
+ emit_formats($id, $format_to_stylesheet_map, $format_info, $cgi);
} elsif ($id) {
# koha:biblionumber:0152018484
} elsif ($id) {
# koha:biblionumber:0152018484
- my $transformer = get_transformer($format);
+ my $transformer = get_transformer($format, $format_to_stylesheet_map, $format_info);
unless (defined $transformer) {
print $cgi->header( -status => '406 invalid format requested' );
exit 0;
unless (defined $transformer) {
print $cgi->header( -status => '406 invalid format requested' );
exit 0;
exit 0;
sub emit_formats {
exit 0;
sub emit_formats {
+ my ($id, $format_to_stylesheet_map, $format_info, $cgi) = @_;
if (defined $id) {
print $cgi->header( -type =>'application/xml', -status => '300 multiple choices' );
if (defined $id) {
print $cgi->header( -type =>'application/xml', -status => '300 multiple choices' );
+ my ($format, $format_to_stylesheet_map, $format_info) = @_;
+ $format = lc $format;
my $marcflavour = uc(C4::Context->preference('marcflavour'));
return unless $format_to_stylesheet_map->{$marcflavour}->{$format};
my $marcflavour = uc(C4::Context->preference('marcflavour'));
return unless $format_to_stylesheet_map->{$marcflavour}->{$format};