| 1 | package # hide from PAUSE | ||||||||||||||||||||||||||||||||
| 2 | DBIx::Class::_Util; | ||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||
| 4 | 308 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | 308 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||
| 7 | 308 | ▶ | use constant SPURIOUS_VERSION_CHECK_WARNINGS => ($] < 5.010 ? 1 : 0); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.1
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||
| 9 | BEGIN { | ||||||||||||||||||||||||||||||||
| 10 | package # hide from pause | ||||||||||||||||||||||||||||||||
| 11 | DBIx::Class::_ENV_; | ||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||
| 13 | 308 | ▶ | use Config; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||
| 15 | use constant { | ||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||
| 17 | # but of course | ||||||||||||||||||||||||||||||||
| 18 | BROKEN_FORK => ($^O eq 'MSWin32') ? 1 : 0, | ||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||
| 20 | HAS_ITHREADS => $Config{useithreads} ? 1 : 0, | ||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | # ::Runmode would only be loaded by DBICTest, which in turn implies t/ | ||||||||||||||||||||||||||||||||
| 23 | 308 | ▶ | DBICTEST => eval { DBICTest::RunMode->is_author } ? 1 : 0, | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
eval {
do {
"DBICTest::RunMode"->is_smoker
}
} and ($] >= "5.013005" and $] <= "5.013006")
MC/DC50%1/2
eval {
do {
"DBICTest::RunMode"->is_smoker
}
} and ($] >= "5.013005" and $] <= "5.013006")
eval {
do {
"DBICTest::RunMode"->is_smoker
}
}
($] >= "5.013005" and $] <= "5.013006")
Truth table66%2/3
A and B
A= eval {
do {
"DBICTest::RunMode"->is_smoker
}
}B= ($] >= "5.013005" and $] <= "5.013006")
| |||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||
| 25 | # During 5.13 dev cycle HELEMs started to leak on copy | ||||||||||||||||||||||||||||||||
| 26 | PEEPEENESS => | ||||||||||||||||||||||||||||||||
| 27 | # request for all tests would force "non-leaky" illusion and vice-versa | ||||||||||||||||||||||||||||||||
| 28 | defined $ENV{DBICTEST_ALL_LEAKS} ? !$ENV{DBICTEST_ALL_LEAKS} | ||||||||||||||||||||||||||||||||
| 29 | # otherwise confess that this perl is busted ONLY on smokers | ||||||||||||||||||||||||||||||||
| 30 | 308 | ▶ | : eval { DBICTest::RunMode->is_smoker } && ($] >= 5.013005 and $] <= 5.013006) ? 1 | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$] >= "5.013005" and $] <= "5.013006"
MC/DC0%0/2
$] >= "5.013005" and $] <= "5.013006"
$] >= "5.013005"
$] <= "5.013006"
Truth table33%1/3
A and B
A= $] >= "5.013005"B= $] <= "5.013006"
| |||||||||||||||||||||||||||||||||
| 31 | # otherwise we are good | ||||||||||||||||||||||||||||||||
| 32 | : 0 | ||||||||||||||||||||||||||||||||
| 33 | , | ||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||
| 35 | ASSERT_NO_INTERNAL_WANTARRAY => $ENV{DBIC_ASSERT_NO_INTERNAL_WANTARRAY} ? 1 : 0, | ||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||
| 37 | IV_SIZE => $Config{ivsize}, | ||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||
| 39 | 308 | ▶ | OS_NAME => $^O, | ||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||
| 40 | 308 | ▶ | }; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||
| 42 | 308 | ▶ | if ($] < 5.009_005) { | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=8.4
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 43 | 0 | require MRO::Compat; | |||||||||||||||||||||||||||||||
| 44 | 0 | constant->import( OLD_MRO => 1 ); | |||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||
| 46 | else { | ||||||||||||||||||||||||||||||||
| 47 | 308 | require mro; | |||||||||||||||||||||||||||||||
| 48 | 308 | constant->import( OLD_MRO => 0 ); | |||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||
| 52 | # FIXME - this is not supposed to be here | ||||||||||||||||||||||||||||||||
| 53 | # Carp::Skip to the rescue soon | ||||||||||||||||||||||||||||||||
| 54 | 308 | ▶ | use DBIx::Class::Carp '^DBIx::Class|^DBICTest'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||
| 56 | 308 | ▶ | use Carp 'croak'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 57 | 308 | ▶ | use Scalar::Util qw(weaken blessed reftype); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||
| 59 | 308 | ▶ | use base 'Exporter'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 60 | 308 | our @EXPORT_OK = qw(sigwarn_silencer modver_gt_or_eq fail_on_internal_wantarray refcount hrefaddr is_exception); | |||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||
| 62 | sub sigwarn_silencer ($) { | ||||||||||||||||||||||||||||||||
| 63 | 15 | ▶ | my $pattern = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
sigwarn_silencer: called CC=3 SCAR=12.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||
| 65 | 15 | ▶ | croak "Expecting a regexp" if ref $pattern ne 'Regexp'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||
| 67 | 15 | ▶ | my $orig_sig_warn = $SIG{__WARN__} || sub { CORE::warn(@_) }; | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.0
Condition33%1/3
$SIG{'__WARN__'} || sub {
warn @_;
}
MC/DC0%0/2
$SIG{'__WARN__'} || sub {
warn @_;
}
$SIG{'__WARN__'}
sub {
warn @_;
}
Truth table33%1/3
A || B
A= $SIG{'__WARN__'}B= sub {
warn @_;
}
| |||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||
| 69 | 15 | ▶ | return sub { &$orig_sig_warn unless $_[0] =~ $pattern }; | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||
| 72 | 57260 | ▶ | sub hrefaddr ($) { sprintf '0x%x', &Scalar::Util::refaddr } | ||||||||||||||||||||||||||||||
|
Subroutine
hrefaddr: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||
| 74 | sub refcount ($) { | ||||||||||||||||||||||||||||||||
| 75 | 35961 | ▶ | croak "Expecting a reference" if ! length ref $_[0]; | ||||||||||||||||||||||||||||||
|
Subroutine
refcount: called CC=2 SCAR=7.1
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||
| 77 | 35961 | require B; | |||||||||||||||||||||||||||||||
| 78 | # No tempvars - must operate on $_[0], otherwise the pad | ||||||||||||||||||||||||||||||||
| 79 | # will count as an extra ref | ||||||||||||||||||||||||||||||||
| 80 | 35961 | B::svref_2object($_[0])->REFCNT; | |||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||
| 83 | sub is_exception ($) { | ||||||||||||||||||||||||||||||||
| 84 | 52125 | ▶ | my $e = $_[0]; | ||||||||||||||||||||||||||||||
|
Subroutine
is_exception: called CC=7 SCAR=23.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||
| 86 | # this is not strictly correct - an eval setting $@ to undef | ||||||||||||||||||||||||||||||||
| 87 | # is *not* the same as an eval setting $@ to '' | ||||||||||||||||||||||||||||||||
| 88 | # but for the sake of simplicity assume the following for | ||||||||||||||||||||||||||||||||
| 89 | # the time being | ||||||||||||||||||||||||||||||||
| 90 | 52125 | ▶ | return 0 unless defined $e; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||
| 92 | 52125 | my ($not_blank, $suberror); | |||||||||||||||||||||||||||||||
| 93 | { | ||||||||||||||||||||||||||||||||
| 94 | 52125 | local $@; | |||||||||||||||||||||||||||||||
| 95 | 52125 | ▶ | eval { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 96 | 52125 | ▶ | $not_blank = ($e ne '') ? 1 : 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 97 | 52125 | 1; | |||||||||||||||||||||||||||||||
| 98 | } or $suberror = $@; | ||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||
| 101 | 52125 | ▶ | if (defined $suberror) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | if (length (my $class = blessed($e) )) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 103 | 0 | carp_unique( sprintf( | |||||||||||||||||||||||||||||||
| 104 | 'External exception object %s=%s(%s) implements partial (broken) ' | ||||||||||||||||||||||||||||||||
| 105 | . 'overloading preventing it from being used in simple ($x eq $y) ' | ||||||||||||||||||||||||||||||||
| 106 | . 'comparisons. Given Perl\'s "globally cooperative" exception ' | ||||||||||||||||||||||||||||||||
| 107 | . 'handling this type of brokenness is extremely dangerous on ' | ||||||||||||||||||||||||||||||||
| 108 | . 'exception objects, as it may (and often does) result in silent ' | ||||||||||||||||||||||||||||||||
| 109 | . '"exception substitution". DBIx::Class tries to work around this ' | ||||||||||||||||||||||||||||||||
| 110 | . 'as much as possible, but other parts of your software stack may ' | ||||||||||||||||||||||||||||||||
| 111 | . 'not be even aware of this. Please submit a bugreport against the ' | ||||||||||||||||||||||||||||||||
| 112 | . 'distribution containing %s and in the meantime apply a fix similar ' | ||||||||||||||||||||||||||||||||
| 113 | . 'to the one shown at %s, in order to ensure your exception handling ' | ||||||||||||||||||||||||||||||||
| 114 | . 'is saner application-wide. What follows is the actual error text ' | ||||||||||||||||||||||||||||||||
| 115 | . "as generated by Perl itself:\n\n%s\n ", | ||||||||||||||||||||||||||||||||
| 116 | $class, | ||||||||||||||||||||||||||||||||
| 117 | reftype $e, | ||||||||||||||||||||||||||||||||
| 118 | hrefaddr $e, | ||||||||||||||||||||||||||||||||
| 119 | $class, | ||||||||||||||||||||||||||||||||
| 120 | 'http://v.gd/DBIC_overload_tempfix/', | ||||||||||||||||||||||||||||||||
| 121 | $suberror, | ||||||||||||||||||||||||||||||||
| 122 | )); | ||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||
| 124 | # workaround, keeps spice flowing | ||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | $not_blank = ("$e" ne '') ? 1 : 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||
| 127 | else { | ||||||||||||||||||||||||||||||||
| 128 | # not blessed yet failed the 'ne'... this makes 0 sense... | ||||||||||||||||||||||||||||||||
| 129 | # just throw further | ||||||||||||||||||||||||||||||||
| 130 | 0 | die $suberror | |||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||
| 134 | 52125 | return $not_blank; | |||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||
| 137 | sub modver_gt_or_eq ($$) { | ||||||||||||||||||||||||||||||||
| 138 | 222 | ▶ | my ($mod, $ver) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
modver_gt_or_eq: called CC=6 SCAR=20.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||
| 140 | 222 | ▶ | croak "Nonsensical module name supplied" | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $mod and length $mod
MC/DC0%0/2
defined $mod and length $mod
defined $mod
length $mod
Truth table33%1/3
A and B
A= defined $modB= length $mod
| |||||||||||||||||||||||||||||||||
| 141 | if ! defined $mod or ! length $mod; | ||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||
| 143 | 222 | ▶ | croak "Nonsensical minimum version supplied" | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $ver or $ver =~ /[^0-9\.\_]/
MC/DC0%0/2
not defined $ver or $ver =~ /[^0-9\.\_]/
not defined $ver
$ver =~ /[^0-9\.\_]/
Truth table33%1/3
not(A) or B
A= not defined $verB= $ver =~ /[^0-9\.\_]/
| |||||||||||||||||||||||||||||||||
| 144 | if ! defined $ver or $ver =~ /[^0-9\.\_]/; | ||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||
| 146 | 222 | local $SIG{__WARN__} = sigwarn_silencer( qr/\Qisn't numeric in subroutine entry/ ) | |||||||||||||||||||||||||||||||
| 147 | if SPURIOUS_VERSION_CHECK_WARNINGS; | ||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||
| 149 | 222 | local $@; | |||||||||||||||||||||||||||||||
| 150 | 222 | ▶ | eval { $mod->VERSION($ver) } ? 1 : 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||
| 153 | { | ||||||||||||||||||||||||||||||||
| 154 | 308 | my $list_ctx_ok_stack_marker; | |||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||
| 156 | sub fail_on_internal_wantarray { | ||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | return if $list_ctx_ok_stack_marker; | ||||||||||||||||||||||||||||||
|
Subroutine
fail_on_internal_wantarray: not called CC=6 SCAR=37.4
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | if (! defined wantarray) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 160 | 0 | croak('fail_on_internal_wantarray() needs a tempvar to save the stack marker guard'); | |||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||
| 163 | 0 | my $cf = 1; | |||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | while ( ( (caller($cf+1))[3] || '' ) =~ / :: (?: | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
(caller $cf + 1)[3] || ''
MC/DC0%0/1
(caller $cf + 1)[3] || ''
(caller $cf + 1)[3]
Truth table0%0/2
A
A= (caller $cf + 1)[3]
| |||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||
| 166 | # these are public API parts that alter behavior on wantarray | ||||||||||||||||||||||||||||||||
| 167 | search | search_related | slice | search_literal | ||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||
| 169 | | | ||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||
| 171 | # these are explicitly prefixed, since we only recognize them as valid | ||||||||||||||||||||||||||||||||
| 172 | # escapes when they come from the guts of CDBICompat | ||||||||||||||||||||||||||||||||
| 173 | CDBICompat .*? :: (?: search_where | retrieve_from_sql | retrieve_all ) | ||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||
| 175 | ) $/x ) { | ||||||||||||||||||||||||||||||||
| 176 | 0 | $cf++; | |||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 180 | (caller($cf))[0] =~ /^(?:DBIx::Class|DBICx::)/ | ||||||||||||||||||||||||||||||||
| 181 | ) { | ||||||||||||||||||||||||||||||||
| 182 | 0 | my $obj = shift; | |||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||
| 184 | 0 | DBIx::Class::Exception->throw( sprintf ( | |||||||||||||||||||||||||||||||
| 185 | "Improper use of %s(%s) instance in list context at %s line %d\n\n\tStacktrace starts", | ||||||||||||||||||||||||||||||||
| 186 | ref($obj), hrefaddr($obj), (caller($cf))[1,2] | ||||||||||||||||||||||||||||||||
| 187 | ), 'with_stacktrace'); | ||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||
| 190 | 0 | my $mark = []; | |||||||||||||||||||||||||||||||
| 191 | 0 | weaken ( $list_ctx_ok_stack_marker = $mark ); | |||||||||||||||||||||||||||||||
| 192 | 0 | $mark; | |||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||
| 196 | 308 | 1; | |||||||||||||||||||||||||||||||