Changeset 661

Show
Ignore:
Timestamp:
07/01/02 18:29:08
Author:
miyagawa
Message:

0.10 release: PHP undef value handling

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • PHP-Session/trunk/Changes

    r660 r661  
    11Revision history for Perl extension PHP::Session 
     2 
     30.10  Mon Jul  1 18:26:54 JST 2002 
     4        * correctly encode/decode undefined value in PHP 
     5          (Thanks to Lupe Christoph) 
    26 
    370.09  Fri Jun 28 04:26:31 JST 2002 
  • PHP-Session/trunk/lib/PHP/Session.pm

    r660 r661  
    33use strict; 
    44use vars qw($VERSION); 
    5 $VERSION = 0.09
     5$VERSION = '0.10'
    66 
    77use vars qw(%SerialImpl); 
  • PHP-Session/trunk/lib/PHP/Session/Serializer/PHP.pm

    r660 r661  
    55 
    66use vars qw($VERSION); 
    7 $VERSION = 0.07
     7$VERSION = '0.10'
    88 
    99sub _croak { require Carp; Carp::croak(@_) } 
     
    3434sub decode { 
    3535    my($self, $data) = @_; 
    36     while ($data and $data =~ s/^$var_re(?:$str_re|$int_re|$dbl_re|$arr_re|$obj_re|$nul_re|$bool_re)//s) { 
    37         my @match = ($1, $2, $3, $4, $5, $6, $7, $8); 
     36    while ($data and $data =~ s/^(!?)$var_re(?:$str_re|$int_re|$dbl_re|$arr_re|$obj_re|$nul_re|$bool_re)?//s) { 
     37        my $UNDEF = $1; 
     38        my @match = ($2, $3, $4, $5, $6, $7, $8, $9); 
    3839        my @literal = grep defined, @match[STRING, INTEGER, DOUBLE, BOOLEAN]; 
    3940        @literal and $self->{_data}->{$match[VARNAME]} = $literal[0], next; 
    4041 
    41         if (defined $match[NULL]) { 
     42        if ($UNDEF eq '!' or defined $match[NULL]) { 
    4243            $self->{_data}->{$match[VARNAME]} = undef; 
    4344            next; 
     
    9293    my $body; 
    9394    for my $key (keys %$data) { 
    94         $body .= "$key|" . $self->do_encode($data->{$key}); 
     95        if (defined $data->{$key}) { 
     96            $body .= "$key|" . $self->do_encode($data->{$key}); 
     97        } else { 
     98            $body .= "!$key|"; 
     99        } 
    95100    } 
    96101    return $body; 
  • PHP-Session/trunk/t/01_deserialize.t

    r550 r661  
    11use strict; 
    2 use Test::More tests => 22
     2use Test::More tests => 24
    33 
    44use lib 't/lib'; 
     
    88 
    99chomp(my $sess = <<'SESSION'); 
    10 baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";s:4:"done";}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";s:4:"done";}} 
     10baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";s:4:"done";}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";s:4:"done";}}!foo| 
    1111SESSION 
    1212    ; 
     
    3333    is $arr->{3}->{yes}, 'done'; 
    3434    $session->destroy; 
     35 
     36    is $session->get('foo'), undef, 'foo is undef'; 
    3537} 
    3638 
    3739chomp(my $sess2 = <<'SESSION'); 
    38 count|i:2;c|i:12;a|a:4:{i:1;s:3:"foo";i:2;O:3:"baz":0:{}i:3;s:3:"bar";i:4;d:-1.2;}d|N; 
     40count|i:2;c|i:12;!foo|a|a:4:{i:1;s:3:"foo";i:2;O:3:"baz":0:{}i:3;s:3:"bar";i:4;d:-1.2;}d|N; 
    3941SESSION 
    4042    ; 
     
    4951    is $session->get('count'), 2; 
    5052    is $session->get('c'), 12; 
     53    is $session->get('foo'), undef, 'foo is undef'; 
     54 
    5155    my $arr = $session->get('a'); 
    5256    is ref($arr), 'HASH'; 
  • PHP-Session/trunk/t/04_save.t

    r550 r661  
    1010 
    1111chomp(my $sess = <<'SESSION'); 
    12 baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";s:4:"done";}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";s:4:"done";}} 
     12baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";s:4:"done";}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";s:4:"done";}}!foo| 
    1313SESSION 
    1414    ; 
     
    2020 
    2121chomp(my $sess2 = <<'SESSION'); 
    22 count|i:2;c|i:12;a|a:4:{i:1;s:3:"foo";i:2;O:3:"baz":0:{}i:3;s:3:"bar";i:4;d:-1.2;}d|N; 
     22count|i:2;c|i:12;!foo|a|a:4:{i:1;s:3:"foo";i:2;O:3:"baz":0:{}i:3;s:3:"bar";i:4;d:-1.2;}d|N; 
    2323SESSION 
    2424    ;