[open-ils-commits] r20391 - branches/rel_2_1/Open-ILS/src/perlmods/lib/OpenILS/WWW (dbs)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue May 3 23:47:22 EDT 2011


Author: dbs
Date: 2011-05-03 23:47:19 -0400 (Tue, 03 May 2011)
New Revision: 20391

Modified:
   branches/rel_2_1/Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat.pm
Log:
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 <dan at coffeecode.net>


Modified: branches/rel_2_1/Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat.pm
===================================================================
--- branches/rel_2_1/Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat.pm	2011-05-04 03:46:27 UTC (rev 20390)
+++ branches/rel_2_1/Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat.pm	2011-05-04 03:47:19 UTC (rev 20391)
@@ -281,7 +281,7 @@
 =cut
 
 sub parse_feed_type {
-    my $type = shift;
+    my $type = shift || '';
 
      if ($type =~ /-full$/o) {
         return 1;
@@ -412,21 +412,22 @@
     # 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")



More information about the open-ils-commits mailing list