From f852ad933b9a6c69836ea186b56cd54aca13044c Mon Sep 17 00:00:00 2001 From: dbs Date: Wed, 4 May 2011 03:46:27 +0000 Subject: [PATCH] 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/trunk@20390 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat.pm | 23 +++++++++++---------- 1 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat.pm index 5287171..d3a6ae8 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") -- 1.7.2.5