Skip to content

Commit

Permalink
Item11983: fixing old bugs poping up now
Browse files Browse the repository at this point in the history
   * calling setEmbeddedStoreForm multiple times on the same obj removed more and more newlines at the end of the topic 
     -> removing all newlines at once replacing it with one left
   * fixed cacheMetaInfo to properly keep all keys in there, including reprev being used for merging properly



git-svn-id: http://svn.foswiki.org/trunk@15385 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
MichaelDaum authored and MichaelDaum committed Sep 18, 2012
1 parent 53408c0 commit 982ae9b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 32 deletions.
4 changes: 2 additions & 2 deletions UnitTestContrib/test/unit/SaveScriptTests.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1166,7 +1166,7 @@ sub test_1897 {
( $info->{date}, $info->{author}, $info->{version} );
$this->assert_equals( 1, $orgRev );
$this->assert_str_equals( "Smelly\ncat", $text );
$this->assert_str_equals( "Smelly\ncat\n", $text );
my $original = "${orgRev}_$orgDate";
sleep(1); # tick the clock to ensure the date changes
Expand Down Expand Up @@ -1223,7 +1223,7 @@ sub test_1897 {
( $info->{date}, $info->{author}, $info->{version} );
$this->assert_equals( 2, $mergeRev );
$this->assert_str_equals(
"<del>Sweaty\n</del><ins>Smelly\n</ins><del>cat\n</del><ins>rat\n</ins>",
"<del>Sweaty\n</del><ins>Smelly\n</ins><del>cat\n</del><ins>rat\n</ins>\n",
$text
);
$meta->finish();
Expand Down
6 changes: 3 additions & 3 deletions core/lib/Foswiki/Meta.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1934,7 +1934,7 @@ sub save {

throw $signal if $signal;

ASSERT( $newRev, $this->{loadedRev} ) if DEBUG;
ASSERT( $newRev, $this->{_loadedRev} ) if DEBUG;

my @extras = ();
push( @extras, 'minor' ) if $opts{minor}; # don't notify
Expand Down Expand Up @@ -3596,8 +3596,8 @@ sub setEmbeddedStoreForm {
}
}

# eat the extra newline put in to separate text from tail meta-data
$text =~ s/\n$//s if $endMeta;
# eat extra newlines put in to separate text from tail meta-data
$text =~ s/\n+$/\n/s if $endMeta;

# If there is no meta data then convert from old format
if ( !$this->count('TOPICINFO') ) {
Expand Down
38 changes: 11 additions & 27 deletions core/lib/Foswiki/Store/VC/Handler.pm
Original file line number Diff line number Diff line change
Expand Up @@ -351,41 +351,25 @@ sub _cacheMetaInfo {
unless defined $user;
$date = time() unless defined $date;

my $info;

# remove the previous record
if ( $text =~ s/^%META:TOPICINFO{(.*)}%\n//m ) {
my $info = Foswiki::Attrs->new($1);

# keep the rev id as is unless specified as parameter
unless ( defined $rev ) {
$rev = $info->{version};
}

# keep comment as is unless specified otherwise
unless ( defined $comment ) {
$comment = $info->{comment};
}
}
$info = Foswiki::Attrs->new($1);

# only store a comment attr when there is one
if ( defined $comment && $comment ne '' ) {
$comment = ' comment="' . $comment . '"';
}
else {
$comment = '';
$info = Foswiki::Attrs->new();
}

$rev ||= 1;
$info->{comment} = $comment if defined $comment && $comment ne '';
$info->{author} = $user;
$info->{date} = $date;
$info->{version} = ( $rev || 1 ) if defined $rev;
$info->{version} ||= 1;
$info->{format} = '1.1';

$text =
'%META:TOPICINFO{'
. 'author="'
. $user . '"'
. $comment
. ' date="'
. $date . '"'
. ' format="1.1" version="'
. $rev . '"}%'
. "\n$text";
$text = "%META:TOPICINFO{" . $info->stringify . "}%\n" . $text;

return $text;
}
Expand Down

0 comments on commit 982ae9b

Please sign in to comment.