Revision 583

Date:
2016/08/24 15:51:24
Author:
ahitrov
Revision Log:
Extra-fields store problem with DBD::Pg 3.*.
Object::eval_dump now evaluates dump only when it has plain structure. For references it returns initial value;

Files:

Legend:

 
Added
 
Removed
 
Modified
  • utf8/core/lib/Contenido/Object.pm

     
    329 329 local $Data::Dumper::Indent = 0;
    330 330 if ($state->db_encode_data) {
    331 331 return Data::Dumper::Dumper({map { $_=> Encode::decode($state->db_encode_data, $self->{$_}, Encode::FB_HTMLCREF) } grep { !$virtual_fields->{$_} && (defined $self->{$_}) } @$extra_fields});
    332 } elsif ( $DBD::Pg::VERSION >= '3' ) {
    333 warn "Store extras: ".Data::Dumper::Dumper({map { $_=>$self->{$_} } grep { !$virtual_fields->{$_} && (defined $self->{$_}) } @$extra_fields});
    334 return Encode::decode( 'utf-8', Data::Dumper::Dumper({map { $_=>$self->{$_} } grep { !$virtual_fields->{$_} && (defined $self->{$_}) } @$extra_fields}) );
    332 335 } else {
    333 336 return Data::Dumper::Dumper({map { $_=>$self->{$_} } grep { !$virtual_fields->{$_} && (defined $self->{$_}) } @$extra_fields});
    334 337 }
     
    1046 1049
    1047 1050 sub eval_dump {
    1048 1051 no strict 'vars';
    1049 return {} unless ${$_[0]};
    1050 return eval ${$_[0]};
    1052 if ( ref ${$_[0]} ) {
    1053 return ${$_[0]};
    1054 } elsif ( ${$_[0]} ) {
    1055 return eval ${$_[0]};
    1056 } else {
    1057 return {};
    1058 }
    1051 1059 }
    1052 1060
    1053 1061 sub eval_json {
     
    1055 1063 my $str = ${$_[0]};
    1056 1064 my $chr = substr($str, 0, 1); return $str unless $chr eq '{' || $chr eq '[';
    1057 1065 my $value = $json_u->decode( $str );
    1058 # map { $_ = Encode::encode(\'utf-8\', $_) unless ref $_; } values %$value;
    1059 1066 return $value;
    1060 1067 }
    1061 1068