Skip Menu |

This queue is for tickets about the Config-General CPAN distribution.

Report information
The Basics
Id: 32978
Status: resolved
Priority: 0/
Queue: Config-General

People
Owner: Nobody in particular
Requestors: acd [...] weirdness.net
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 2.37
Fixed in: 2.37



Subject: Providing array reference to -String is broken
-String option no longer takes array references as documented. This is a regression from 2.27 which was the last version I used. Patch attached with a fix and test case.
Subject: Config-General-2.37.string-ref-fix.diff
diff -ru Config-General-2.37/General.pm Config-General-2.37.acd/General.pm --- Config-General-2.37/General.pm 2007-11-24 16:07:36.000000000 -0500 +++ Config-General-2.37.acd/General.pm 2008-02-06 13:35:48.937741911 -0500 @@ -287,20 +287,20 @@ # handle options which contains values we need (strings, hashrefs or the like) if (exists $conf{-String} ) { - if (ref(\$conf{-String}) eq 'SCALAR') { - if ( $conf{-String}) { - $self->{StringContent} = $conf{-String}; + if (not ref $conf{-String}) { + if ($conf{-String}) { + $self->{StringContent} = $conf{-String}; } - delete $conf{-String}; } # re-implement arrayref support, removed after 2.22 as _read were # re-organized - elsif(ref(\$conf{-String}) eq 'ARRAY') { - $self->{StringContent} = join '\n', @{$conf{-String}}; + elsif(ref $conf{-String} eq 'ARRAY') { + $self->{StringContent} = join("\n", @{$conf{-String}}); } else { - croak "Config::General: Parameter -String must be a SCALAR!\n"; + croak "Config::General: Parameter -String must be a SCALAR or ARRAYREF!\n"; } + delete $conf{-String}; } if (exists $conf{-Tie}) { diff -ru Config-General-2.37/t/run.t Config-General-2.37.acd/t/run.t --- Config-General-2.37/t/run.t 2007-11-24 16:09:34.000000000 -0500 +++ Config-General-2.37.acd/t/run.t 2008-02-06 13:50:31.219371084 -0500 @@ -8,7 +8,7 @@ use Data::Dumper; -use Test::More tests => 43; +use Test::More tests => 45; #use Test::More qw(no_plan); ### 1 @@ -450,3 +450,10 @@ }; ok($@ =~ /^Config::General/, "$pos: Structural error checks"); } + +my $conf44; +eval { + $conf44 = new Config::General(-String => [ 'foo bar' ]); +}; +ok(! $@, "-String arrayref"); +is_deeply({ $conf44->getall }, { foo => 'bar' }, "-String arrayref contents");
fixed in 2.38