Skip to content

Commit

Permalink
Item13062: there's a very real difference between values being string…
Browse files Browse the repository at this point in the history
…ified for presentation, and those being stored - principally the use of quotes. The only way to resolve this is to acknowledge the data type
  • Loading branch information
Comment committed Dec 3, 2014
1 parent 780e8bc commit bf85d43
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
10 changes: 9 additions & 1 deletion core/lib/Foswiki/Configure/Query.pm
Expand Up @@ -500,8 +500,16 @@ sub wizard {
my $response = $target->$method($reporter);
return $response if $response;

# Note: we can't used the value recorded at CHANGED time because that
# is encoded using Reporter::uneval, which knows nothing about the
# real type of the value. For the real type we have to use the
# Value's encoder.
my %new_values = map {
$_ => $root->getValueObject($_)->encodeValue( eval "\$Foswiki::cfg$_" )
} keys %{ $reporter->{changes} };

return {
changes => $reporter->changes(),
changes => \%new_values,
messages => $reporter->messages()
};
}
Expand Down
14 changes: 6 additions & 8 deletions core/lib/Foswiki/Configure/Reporter.pm
Expand Up @@ -284,23 +284,21 @@ $Data::Dumper::Indent. See perldoc Data::Dumper for more information.

sub uneval {
my ( $datum, $indent ) = @_;
my $d;
if ( ref($datum) eq 'Regexp' ) {

# Convert to string
$d = "$datum";
$datum = "$datum";

# Strip off useless furniture (?^: ... )
$d =~ s/^\(\?\^:(.*)\)$/$1/;
$datum = $d;
$datum =~ s/^\(\?\^:(.*)\)$/$1/;
}
local $Data::Dumper::Sortkeys = 1;
local $Data::Dumper::Terse = 1;
local $Data::Dumper::Indent = $indent || 0;
$d = Data::Dumper->Dump( [$datum] );
$d =~ s/^\$VAR1\s*=\s*//s;
$d =~ s/;\s*$//s;
return $d;
$datum = Data::Dumper->Dump( [$datum] );
$datum =~ s/^\$VAR1\s*=\s*//s;
$datum =~ s/;\s*$//s;
return $datum;
}

=begin TML
Expand Down
8 changes: 4 additions & 4 deletions core/lib/Foswiki/Configure/Value.pm
Expand Up @@ -318,17 +318,17 @@ sub encodeValue {

return undef unless defined $value;

if ( $this->{typename} eq 'BOOLEAN' ) {
$value = $value ? 1 : 0;
if ( ref($value) || $this->{typename} eq 'BOOLEAN' ) {
return Foswiki::Configure::Reporter::uneval($value);
}
return Foswiki::Configure::Reporter::uneval($value);
return $value;
}

=begin TML
---++ ObjectMethod decodeValue($encoded_value) -> $raw_value
Decode a string that represents the value (e.g a serialsed perl structure)
Decode a string that represents the value (e.g a serialised perl structure)
and return the 'true' value by applying type rules
=cut
Expand Down

0 comments on commit bf85d43

Please sign in to comment.