OpenInteract/Session/DBI.pm untested

filter: Statementstmt 0.0% 0 / 29 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 11 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 0.0% 0 / 3 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 57 CC 4 SCAR 26.4
CC
4
Cov
0%
_create_session
20.0
BEGIN
2.0
BEGIN
2.0
CRAP 14.0
1 package OpenInteract::Session::DBI;
2  
3 # $Id: DBI.pm,v 1.10 2002/09/08 20:52:44 lachoy Exp $
4  
5 use strict;
6 use base qw( OpenInteract::Session );
7  
8 $OpenInteract::Session::DBI::VERSION = sprintf("%d.%02d", q$Revision: 1.10 $ =~ /(\d+)\.(\d+)/);
9  
10 sub _create_session {
11 my ( $class, $session_id ) = @_;
12 my $R = OpenInteract::Request->instance;
13 my $CONFIG = $R->CONFIG;
14 my $session_class = $CONFIG->{session_info}{class};
15 my $session_params = $CONFIG->{session_info}{params} || {};
16 my $datasource = $CONFIG->{session_info}{datasource} ||
17 $CONFIG->{datasource}{default_connection_db};
18 $session_params->{Handle} = $R->db( $datasource );
19  
20 # Detect Apache::Session::MySQL and modify parameters
21 # appropriately
22  
23 if ( $session_class =~ /MySQL$/ ) {
24 $session_params->{LockHandle} = $session_params->{Handle};
25 $R->DEBUG && $R->scrib( 2, "Using MySQL session store, with LockHandle parameter" );
26 }
27 my %session = ();
28 $R->DEBUG && $R->scrib( 1, "Trying to fetch session [$session_id]" );
29 eval { tie %session, $session_class, $session_id, $session_params };
30 if ( $@ ) {
31 $R->throw({ code => 310,
32 type => 'session',
33 system_msg => $@,
34 extra => { class => $session_class,
35 session_id => $session_id } });
36 $R->scrib( 0, "Error thrown. Now clear the cookie" );
37 return undef;
38 }
39  
40 # Only return the session if it's not empty
41 return \%session if ( scalar keys %session );
42 return undef;
43 }
44  
45 1;
46  
47 __END__