blib/lib/Lemonldap/NG/Common/Conf/Backends/CDBI.pm

filter: Statementstmt 82.9% 34 / 41 Branchbran 50.0% 6 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 2 totaltotal 75.4% 46 / 61 CC 7 SCAR 13.8
CC
7
Cov
75%
load
6.9
store
3.0
BEGIN
1.0
CRAP 4.0
« blib/lib/Lemonldap/NG/Common/PSGI/SOAPServer.pm ↑ Summary blib/lib/Lemonldap/NG/Common/Util/Crypto.pm »
1 package Lemonldap::NG::Common::Conf::Backends::CDBI;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use Lemonldap::NG::Common::Conf::Backends::_DBI;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 our $VERSION = '2.22.0';
9 3 our @ISA = qw(Lemonldap::NG::Common::Conf::Backends::_DBI);
10  
11 15 ▶sub store {
Subroutine store: called CC=3 SCAR=11.1
Pod undocumented
12 15 my ( $self, $fields ) = @_;
13 15 my $cfgNum = $fields->{cfgNum};
14 15 my $req;
15 15 my $lastCfg = $self->lastCfg;
16  
17 15 $fields = to_json($fields);
18  
19 15 ▶ my $query =
Branch: 1 branch
BranchTrueFalseTotal
$lastCfg == $cfgNum ? : 0 15 15
20 $lastCfg == $cfgNum
21 ? "UPDATE $self->{dbiTable} SET data=? WHERE cfgNum=?"
22 : "INSERT INTO $self->{dbiTable} (data,cfgNum) VALUES (?,?)";
23 15 my $res = $self->_execute( $query, $fields, $cfgNum );
24 8 ▶ return $res > 0 ? $cfgNum : $res;
Branch: 1 branch
BranchTrueFalseTotal
$res > 0 ? : 8 0 8
25 }
26  
27 9 ▶sub load {
Subroutine load: called CC=5 SCAR=19.3
Pod undocumented
28 9 my ( $self, $cfgNum, $fields ) = @_;
29 9 ▶ $fields = $fields ? join( ",", @$fields ) : '*';
Branch: 1 branch
BranchTrueFalseTotal
$fields ? : 0 9 9
30 my ( $res, $row ) = $self->_execute(
31 9 "SELECT data from " . $self->{dbiTable} . " WHERE cfgNum=?", $cfgNum );
32 9 ▶ if ( $res > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res > 0) { } 9 0 9
33 9 $row = $row->fetchrow_arrayref();
34 }
35 else {
36 0 $self->logError;
37 0 return 0;
38 }
39 9 my $r;
40 9 ▶ if ( $row->[0] =~ /^\s*\{/s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($row->[0] =~ /^\s*\{/s) { } 9 0 9
41 9 eval { $r = from_json( $row->[0], { allow_nonref => 1 } ); };
42 }
43 else { # Old format
44 0 require Storable;
45 0 eval { $r = Storable::thaw( $row->[0] ); };
46 }
47 9 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 9 9
48 0 $Lemonldap::NG::Common::Conf::msg .=
49 "Bad stored data in conf database: $@ \n";
50 0 return 0;
51 }
52 9 return $r;
53 }
54  
55 3 1;
56 __END__
« blib/lib/Lemonldap/NG/Common/PSGI/SOAPServer.pm ↑ Summary blib/lib/Lemonldap/NG/Common/Util/Crypto.pm »