Skip to content

Commit

Permalink
Item9502: Use default values for revision numbers for change summary …
Browse files Browse the repository at this point in the history
…if the values supplied aren't numeric or aren't in the proper order.

git-svn-id: http://svn.foswiki.org/trunk@8596 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
MichaelTempest authored and MichaelTempest committed Aug 19, 2010
1 parent 14a9e2f commit f7d7f63
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions core/lib/Foswiki/Meta.pm
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ use warnings;
use Error qw(:try);
use Assert;
use Errno 'EINTR';
use Scalar::Util ();

our $reason;
our $VERSION = '$Rev$';
Expand Down Expand Up @@ -3132,9 +3133,9 @@ sub summariseChanges {

ASSERT( $this->{_web} && $this->{_topic}, 'this is not a topic object' )
if DEBUG;
$nrev = $this->getLatestRev() unless $nrev;
$nrev = $this->getLatestRev() unless $nrev and _looks_like_number($nrev);

$orev = $nrev - 1 unless defined($orev);
$orev = $nrev - 1 unless defined($orev) and _looks_like_number($orev) and $nrev >= $orev;

ASSERT( $orev >= 0 ) if DEBUG;
ASSERT( $nrev >= $orev ) if DEBUG;
Expand Down Expand Up @@ -3569,6 +3570,15 @@ sub dataDecode {
return $datum;
}

sub _looks_like_number {
if (0 and $] >= 5.008001) {
return Scalar::Util::looks_like_number( $_[0] );
}
else {
return (defined $_[0] && $_[0] =~ /^\s*[+-]?\d+\s*$/);
}
}

1;
__END__
Module of Foswiki - The Free and Open Source Wiki, http://foswiki.org/, http://Foswiki.org/
Expand Down

0 comments on commit f7d7f63

Please sign in to comment.