SuperCat fixes - Child Init
authorThomas Berezansky <tsbere@mvlc.org>
Tue, 10 Apr 2012 13:10:46 +0000 (09:10 -0400)
committerBill Erickson <berick@esilibrary.com>
Wed, 15 Aug 2012 17:54:22 +0000 (13:54 -0400)
Sometimes it seems that child_init has not run properly for supercat.

This attempts to fix that by checking for the global appsession objects. If
they are not there we run child_init. The function that does this is being
called from all handler entry functions.

Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Signed-off-by: Bill Erickson <berick@esilibrary.com>

Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat.pm

index f47ad27..bc33b81 100644 (file)
@@ -273,6 +273,14 @@ sub child_init {
     }
 }
 
+sub check_child_init() {
+    if (!defined $supercat || !defined $actor || !defined $search) {
+        # For some reason one (or more) of our appsessions is missing....
+        # So init!
+        child_init();
+    }
+}
+
 =head2 parse_feed_type($type)
 
 Determines whether and how a given feed type needs to be "fleshed out"
@@ -367,6 +375,8 @@ sub oisbn {
     my $apache = shift;
     return Apache2::Const::DECLINED if (-e $apache->filename);
 
+    check_child_init();
+
     (my $isbn = $apache->path_info) =~ s{^.*?([^/]+)$}{$1}o;
 
     my $list = $supercat
@@ -398,6 +408,8 @@ sub unapi {
     my $apache = shift;
     return Apache2::Const::DECLINED if (-e $apache->filename);
 
+    check_child_init();
+
     my $cgi = new CGI;
 
     my $add_path = 0;
@@ -727,6 +739,8 @@ sub supercat {
     my $apache = shift;
     return Apache2::Const::DECLINED if (-e $apache->filename);
 
+    check_child_init();
+
     my $cgi = new CGI;
 
     my $add_path = 0;
@@ -966,6 +980,8 @@ sub bookbag_feed {
     my $apache = shift;
     return Apache2::Const::DECLINED if (-e $apache->filename);
 
+    check_child_init();
+
     my $cgi = new CGI;
 
     my $year = (gmtime())[5] + 1900;
@@ -1056,6 +1072,8 @@ sub changes_feed {
     my $apache = shift;
     return Apache2::Const::DECLINED if (-e $apache->filename);
 
+    check_child_init();
+
     my $cgi = new CGI;
 
     my $year = (gmtime())[5] + 1900;
@@ -1203,6 +1221,8 @@ sub opensearch_feed {
     my $apache = shift;
     return Apache2::Const::DECLINED if (-e $apache->filename);
 
+    check_child_init();
+
     my $cgi = new CGI;
     my $year = (gmtime())[5] + 1900;
 
@@ -1518,6 +1538,8 @@ sub string_browse {
     my $apache = shift;
     return Apache2::Const::DECLINED if (-e $apache->filename);
 
+    check_child_init();
+
     my $cgi = new CGI;
     my $year = (gmtime())[5] + 1900;
 
@@ -1601,6 +1623,8 @@ sub string_startwith {
     my $apache = shift;
     return Apache2::Const::DECLINED if (-e $apache->filename);
 
+    check_child_init();
+
     my $cgi = new CGI;
     my $year = (gmtime())[5] + 1900;
 
@@ -1812,6 +1836,8 @@ my $ex_doc;
 sub sru_search {
     my $cgi = new CGI;
 
+    check_child_init();
+
     my $req = SRU::Request->newFromCGI( $cgi );
     my $resp = SRU::Response->newFromRequest( $req );
 
@@ -2022,6 +2048,8 @@ my $auth_ex_doc;
 sub sru_auth_search {
     my $cgi = new CGI;
 
+    check_child_init();
+
     my $req = SRU::Request->newFromCGI( $cgi );
     my $resp = SRU::Response->newFromRequest( $req );