| 1 | package Web::Session::Store::MariaDBJSON; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 10 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 10 | ▶ | use DBI; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 10 | ▶ | use Apache::Session::Store::MySQL; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 10 | ▶ | use Web::Session::Store::DBI; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | # Only id and a_session are written: indexed fields are generated columns | ||||||||||||||||||||||||||||
| 10 | 10 | our @ISA = qw(Apache::Session::Store::MySQL); | |||||||||||||||||||||||||||
| 11 | 10 | our $VERSION = '1.0.0'; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | # DBD::MariaDB always uses utf8mb4. DBD::mysql only selects the connection | ||||||||||||||||||||||||||||
| 14 | # charset from attributes given to connect(): setting mysql_enable_utf8 on an | ||||||||||||||||||||||||||||
| 15 | # open handle leaves the default charset of the client library (latin1 on | ||||||||||||||||||||||||||||
| 16 | # some builds) | ||||||||||||||||||||||||||||
| 17 | 13 | ▶ | sub connectAttributes { | ||||||||||||||||||||||||||
|
Subroutine
connectAttributes: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 18 | 13 | my ( $class, $datasource ) = @_; | |||||||||||||||||||||||||||
| 19 | 13 | my %attr = ( RaiseError => 1, AutoCommit => 1 ); | |||||||||||||||||||||||||||
| 20 | 13 | ▶ | $attr{mysql_enable_utf8mb4} = 1 if ( $datasource =~ /^dbi:mysql\b/i ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | 13 | return \%attr; | |||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 7 | ▶ | sub connection { | ||||||||||||||||||||||||||
|
Subroutine
connection: called CC=9 SCAR=22.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 25 | 7 | my ( $self, $session ) = @_; | |||||||||||||||||||||||||||
| 26 | 7 | my $args = $session->{args}; | |||||||||||||||||||||||||||
| 27 | 7 | Web::Session::Store::DBI::_forgetInheritedHandle($self); | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | # Same as Apache::Session::Store::MySQL, with the right connection | ||||||||||||||||||||||||||||
| 30 | # attributes | ||||||||||||||||||||||||||||
| 31 | 7 | ▶ | unless ( defined $self->{dbh} or exists $args->{Handle} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $self->{"dbh"} or exists $args->{"Handle"}
MC/DC50%1/2
defined $self->{"dbh"} or exists $args->{"Handle"}
defined $self->{"dbh"}
exists $args->{"Handle"}
Truth table66%2/3
A or B
A= defined $self->{"dbh"}B= exists $args->{"Handle"}
| |||||||||||||||||||||||||||||
| 32 | my $datasource = $args->{DataSource} | ||||||||||||||||||||||||||||
| 33 | 6 | ▶ | || $Apache::Session::Store::MySQL::DataSource; | ||||||||||||||||||||||||||
|
Condition33%1/3
$args->{'DataSource'} || $Apache::Session::Store::MySQL::DataSource
MC/DC0%0/2
$args->{'DataSource'} || $Apache::Session::Store::MySQL::DataSource
$args->{'DataSource'}
$Apache::Session::Store::MySQL::DataSource
Truth table33%1/3
A || B
A= $args->{'DataSource'}B= $Apache::Session::Store::MySQL::DataSource
| |||||||||||||||||||||||||||||
| 34 | my $username = $args->{UserName} | ||||||||||||||||||||||||||||
| 35 | 6 | ▶ | || $Apache::Session::Store::MySQL::UserName; | ||||||||||||||||||||||||||
|
Condition66%2/3
$args->{'UserName'} || $Apache::Session::Store::MySQL::UserName
MC/DC50%1/2
$args->{'UserName'} || $Apache::Session::Store::MySQL::UserName
$args->{'UserName'}
$Apache::Session::Store::MySQL::UserName
Truth table66%2/3
A || B
A= $args->{'UserName'}B= $Apache::Session::Store::MySQL::UserName
| |||||||||||||||||||||||||||||
| 36 | my $password = $args->{Password} | ||||||||||||||||||||||||||||
| 37 | 6 | ▶ | || $Apache::Session::Store::MySQL::Password; | ||||||||||||||||||||||||||
|
Condition66%2/3
$args->{'Password'} || $Apache::Session::Store::MySQL::Password
MC/DC50%1/2
$args->{'Password'} || $Apache::Session::Store::MySQL::Password
$args->{'Password'}
$Apache::Session::Store::MySQL::Password
Truth table66%2/3
A || B
A= $args->{'Password'}B= $Apache::Session::Store::MySQL::Password
| |||||||||||||||||||||||||||||
| 38 | $self->{table_name} = | ||||||||||||||||||||||||||||
| 39 | 6 | ▶ | $args->{TableName} || $Apache::Session::Store::DBI::TableName; | ||||||||||||||||||||||||||
|
Condition66%2/3
$args->{'TableName'} || $Apache::Session::Store::DBI::TableName
MC/DC0%0/2
$args->{'TableName'} || $Apache::Session::Store::DBI::TableName
$args->{'TableName'}
$Apache::Session::Store::DBI::TableName
Truth table66%2/3
A || B
A= $args->{'TableName'}B= $Apache::Session::Store::DBI::TableName
| |||||||||||||||||||||||||||||
| 40 | 6 | my $attr = $self->connectAttributes($datasource); | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | # Connection reuse (default), see Web::Session::Store::DBI. This | ||||||||||||||||||||||||||||
| 43 | # store doesn't inherit from it: it writes only id and a_session | ||||||||||||||||||||||||||||
| 44 | 6 | ▶ | if ( my $dbh = | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | Web::Session::Store::DBI::_reusedHandle( $self, $args, | ||||||||||||||||||||||||||||
| 46 | $datasource, $username, $password, $attr ) ) | ||||||||||||||||||||||||||||
| 47 | { | ||||||||||||||||||||||||||||
| 48 | 5 | $self->{dbh} = $dbh; | |||||||||||||||||||||||||||
| 49 | 5 | $self->{disconnect} = 0; | |||||||||||||||||||||||||||
| 50 | 5 | return; | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | $self->{dbh} = | ||||||||||||||||||||||||||||
| 53 | 1 | ▶ | DBI->connect( $datasource, $username, $password, $attr ) | ||||||||||||||||||||||||||
|
Condition50%1/2
'DBI'->connect($datasource, $username, $password, $attr) || die($DBI::errstr)
MC/DC0%0/1
'DBI'->connect($datasource, $username, $password, $attr) || die($DBI::errstr)
'DBI'->connect($datasource, $username, $password, $attr)
Truth table50%1/2
A
A= 'DBI'->connect($datasource, $username, $password, $attr)
| |||||||||||||||||||||||||||||
| 54 | || die $DBI::errstr; | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | # If we open the connection, we close the connection | ||||||||||||||||||||||||||||
| 57 | 1 | $self->{disconnect} = 1; | |||||||||||||||||||||||||||
| 58 | 1 | return; | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | 1 | $self->SUPER::connection($session); | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | # update() and materialize() of Apache::Session::Store::DBI, keeping the | ||||||||||||||||||||||||||||
| 64 | # serialized data that the database holds: update() doesn't rewrite an | ||||||||||||||||||||||||||||
| 65 | # unchanged session, as the stores inheriting from Web::Session::Store::DBI | ||||||||||||||||||||||||||||
| 66 | # (see "Unchanged sessions are not rewritten" there). Generated columns are | ||||||||||||||||||||||||||||
| 67 | # computed from a_session: unchanged too | ||||||||||||||||||||||||||||
| 68 | 4 | ▶ | sub update { | ||||||||||||||||||||||||||
|
Subroutine
update: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 69 | 4 | my ( $self, $session ) = @_; | |||||||||||||||||||||||||||
| 70 | 4 | ▶ | return if ( Web::Session::Store::DBI::_unchanged( $self, $session ) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | 2 | $self->SUPER::update($session); | |||||||||||||||||||||||||||
| 72 | 2 | Web::Session::Store::DBI::_remember( $self, $session ); | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 1 | ▶ | sub materialize { | ||||||||||||||||||||||||||
|
Subroutine
materialize: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 76 | 1 | my ( $self, $session ) = @_; | |||||||||||||||||||||||||||
| 77 | 1 | $self->SUPER::materialize($session); | |||||||||||||||||||||||||||
| 78 | 1 | Web::Session::Store::DBI::_remember( $self, $session ); | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 10 | 1; | |||||||||||||||||||||||||||