]> sipb.mit.edu Git - ikiwiki.git/commitdiff
work around CGI::Session constructor issues
authorJoey Hess <joey@kodama.kitenet.net>
Thu, 10 Jul 2008 17:16:03 +0000 (13:16 -0400)
committerJoey Hess <joey@kodama.kitenet.net>
Thu, 10 Jul 2008 17:17:56 +0000 (13:17 -0400)
The constructor can fail with a useless error message if module fail to
load. Work around this by evaling it, and checking for failures, and
printing CGI::Session->errstr to get a more useful message.

IkiWiki/CGI.pm

index 99cead64fcbbf5461820720c415f5eb91e8a58fc..52d3474f57d7cfefb2910341ea0cf96729ce756b 100644 (file)
@@ -645,8 +645,14 @@ sub cgi_getsession ($) { #{{{
        CGI::Session->name("ikiwiki_session_".encode_utf8($config{wikiname}));
        
        my $oldmask=umask(077);
-       my $session = CGI::Session->new("driver:DB_File", $q,
-               { FileName => "$config{wikistatedir}/sessions.db" });
+       my $session = eval {
+               CGI::Session->new("driver:DB_File", $q,
+                       { FileName => "$config{wikistatedir}/sessions.db" })
+       };
+       if (! $session || $@) {
+               error($@." ".CGI::Session->errstr());
+       }
+       
        umask($oldmask);
 
        return $session;