Skip Menu |

This queue is for tickets about the PHP-Session CPAN distribution.

Report information
The Basics
Id: 49953
Status: new
Priority: 0/
Queue: PHP-Session

People
Owner: Nobody in particular
Requestors: FAGZAL [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: empty session file throws error
When PHP creates a session, it creates the cookie and the session file. The session file is empty at this point. PHP::Session does not like this. At "sub _parse_session", the content is checked as: if (!$cont && !$self->{create}) { _croak($self->_file_path, ": $!"); } Which throws a weird error message when the session is empty. I think it would be better if _slurp_content would return undef is the session file is not -f, and and empty string if it exists but empty, and then _parse_session could check for "defined". Something like: sub _parse_session { my $self = shift; my $cont = $self->_slurp_content; if (!defined($cont) && !$self->{create}) { _croak($self->_file_path, " probably unaccessible or does not exist: $!"); } $self->{_data} = $self->decode($cont); } sub _slurp_content { my $self = shift; return undef unless (-f $self->_file_path); my $handle = FileHandle->new($self->_file_path) or return undef; binmode $handle; flock $handle, LOCK_SH; local $/ = undef; my $data = <$handle>; $handle->close; return $data; }