From 92bb47fce0d27b55b81426fa92326e8688f86528 Mon Sep 17 00:00:00 2001 From: Jared Camins-Esakov Date: Fri, 19 Apr 2013 22:52:07 -0400 Subject: [PATCH] Bug 10085: unapi does not function under Plack 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 --- opac/unapi | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/opac/unapi b/opac/unapi index 0f97ece..af0c8db 100755 --- a/opac/unapi +++ b/opac/unapi @@ -107,7 +107,7 @@ my $id = $cgi->param('id'); my $format = $cgi->param('format'); if (not defined $format) { - emit_formats($id); + emit_formats($id, $format_to_stylesheet_map, $format_info, $cgi); } elsif ($id) { # koha:biblionumber:0152018484 @@ -123,7 +123,7 @@ if (not defined $format) { exit 0; } - 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; @@ -154,7 +154,7 @@ if (not defined $format) { exit 0; sub emit_formats { - my $id = shift; + my ($id, $format_to_stylesheet_map, $format_info, $cgi) = @_; if (defined $id) { print $cgi->header( -type =>'application/xml', -status => '300 multiple choices' ); @@ -179,7 +179,8 @@ sub emit_formats { sub get_transformer { - my $format = lc shift; + 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}; -- 1.7.9.5