From: dbs Date: Wed, 4 May 2011 03:47:19 +0000 (+0000) Subject: Prevent uninitialized var warnings in OpenILS::WWW::SuperCat::unapi X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=f3227543c4a65bca81ce16caa8b3c18b565363d8;p=evergreen%2Ftadl.git Prevent uninitialized var warnings in OpenILS::WWW::SuperCat::unapi Given a tag URI like tag:localhost,2011:biblio-record_entry/1 with no format, Evergreen was throwing uninitialized variable warnings and attempting to invoke "open-ils.supercat..formats" due to the unitialized $type variable, which resulted in an Apache error. On the TT OPAC, this enables Zotero to successfully offer import of all entries on the search results page. On the AjaxPAC, it seems that Zotero parses the page before the unAPI hrefs have been supplied by JavaScript. Signed-off-by: Dan Scott git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_2_1@20391 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat.pm index 528717131b..d3a6ae8953 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat.pm @@ -281,7 +281,7 @@ Otherwise, we won't return any holdings. =cut sub parse_feed_type { - my $type = shift; + my $type = shift || ''; if ($type =~ /-full$/o) { return 1; @@ -412,21 +412,22 @@ sub unapi { # Enable localized results of copy status, etc $supercat->session_locale($locale); - my $format = $cgi->param('format'); + my $format = $cgi->param('format') || ''; my $flesh_feed = parse_feed_type($format); (my $base_format = $format) =~ s/(-full|-uris)$//o; - my ($id,$type,$command,$lib,$depth,$paging) = ('','',''); + my ($id,$type,$command,$lib,$depth,$paging) = ('','record',''); + my $body = "Content-type: application/xml; charset=utf-8\n\n"; + + if ($uri =~ m{^tag:[^:]+:([^\/]+)/([^\/[]+)(?:\[([0-9,]+)\])?(?:/(.+))?}o) { + $id = $2; + $paging = $3; + ($lib,$depth) = split('/', $4); + $type = 'metarecord' if ($1 =~ /^m/o); + $type = 'authority' if ($1 =~ /^authority/o); + } if (!$format) { - my $body = "Content-type: application/xml; charset=utf-8\n\n"; - if ($uri =~ m{^tag:[^:]+:([^\/]+)/([^\/[]+)(?:\[([0-9,]+)\])?(?:/(.+))?}o) { - $id = $2; - $paging = $3; - ($lib,$depth) = split('/', $4); - $type = 'record'; - $type = 'metarecord' if ($1 =~ /^m/o); - $type = 'authority' if ($1 =~ /^authority/o); my $list = $supercat ->request("open-ils.supercat.$type.formats")