Subject: | $ENV{ TMPDIR } gets autovivifed in File::Spec::Win32::tmpdir() |
Hi!
This took me some time to catch, but Catalyst was throwing some errors in a section of code that looked like this:
local %ENV = ( ..., %ENV );
warning:
Use of uninitialized value in list assignment at C:/Perl/site/lib/Catalyst/Engine/HTTP.pm line 185.
Apparently, Catalyst::Plugin::Session::Store::File uses Cache::FileCache, which will store files in a temp directory which it calculates via File::Spec::tmpdir(). Because of the way _tmpdir() is called from that function:
# line 63 of Win32.pm
$tmpdir = $self->_tmpdir( @ENV{qw(TMPDIR TEMP TMP)},
this will auto-vivify those keys in the %ENV hash -- and thus Catalyst will throw errors because there are now undef values in that hash!
I propose that like 63 be writted as:
$tmpdir = $self->_tmpdir( $ENV{TMPDIR}, $ENV{TEMP}, $ENV{TMP},
See the attached test file for a quick example.
Cheers,
-Brian
use Test::More tests => 2;
x( $ENV{ TMPDIR } );
ok( !exists $ENV{ TMPDIR } );
x( @ENV{ qw( TMPDIR ) } );
ok( !exists $ENV{ TMPDIR } );
sub x { }