Skip to content

Commit

Permalink
Item12180: Add and verify version
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk@15970 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
TimotheLitt authored and TimotheLitt committed Nov 10, 2012
1 parent 65a352a commit d144806
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
11 changes: 10 additions & 1 deletion core/lib/Foswiki/Configure/Feedback/Cart.pm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Holds changes across sessions (esp. timeouts).
=cut

use constant majorVersion => '1';
use constant minorVersion => '0';

# ######################################################################
# new - create a new cart from %updated keys and $query values
# ######################################################################
Expand All @@ -18,7 +21,10 @@ sub new {
my $class = shift;
my ( $query, $updated ) = @_;

my $cart = { time => time };
my $cart = {
version => sprintf( "%d.%d", majorVersion, minorVersion ),
time => time,
};

foreach my $keys ( keys %$updated ) {
next if ( $keys =~ /^\{ConfigureGUI\}/ );
Expand Down Expand Up @@ -56,6 +62,9 @@ sub loadQuery {
my $cart = shift;
my ($query) = @_;

my $version = $cart->{version} || '1.0'; # Do not update default
return undef unless ( $version =~ /^(\d+)\.(\d+)$/ && $1 == majorVersion );

foreach my $param ( keys %{ $cart->{param} } ) {
$query->param( $param, @{ $cart->{param}{$param} } );
}
Expand Down
14 changes: 10 additions & 4 deletions core/lib/Foswiki/Configure/MainScreen.pm
Original file line number Diff line number Diff line change
Expand Up @@ -830,12 +830,18 @@ sub configureScreen {
if ( !$unsavedChangesNotice && ( my $cart = $session->param('pending') ) ) {
require Foswiki::Configure::Feedback::Cart;

$cart->loadQuery($query);

my $timeSaved = $cart->loadQuery($query);
my %updated;
$valuer->loadCGIParams( $query, \%updated );
if ( defined $timeSaved ) {
$valuer->loadCGIParams( $query, \%updated );
}
else { # Problem with saved cart
$session->clear('pending');
$session->flush;
}
$unsavedChangesNotice =
unsavedChangesNotice( \%updated, $newLogin, $cart->timeSaved );
unsavedChangesNotice( \%updated, $newLogin && $timeSaved,
$timeSaved );
}
else {
# Unless we already have status of unsaved changes, generate "none" status
Expand Down

0 comments on commit d144806

Please sign in to comment.