Fixed a bug where VersionTag->get would return unsafe copies. Also added tests for this.

This commit is contained in:
Martin Kamerbeek 2009-07-15 06:50:33 +00:00
parent 40fcbb5fa9
commit 0f70c99873
3 changed files with 22 additions and 2 deletions

View file

@ -8,6 +8,8 @@
- fixed #10621: ThingRecord needs an Asset Icon
- fixed #10638: Paste from Admin Bar broken
- fixed per-field prices in ThingyRecord
- fixed a bug where VersionTag->get would return an unsafe copy of its
state ( Martin Kamerbeek / Oqapi )
7.7.14
- fixed #10606: shelf selector

View file

@ -247,7 +247,7 @@ sub get {
return $self->{_data}{$name};
}
else {
return \%{ $self->{_data} },
return { %{ $self->{_data} } },
}
}

View file

@ -14,7 +14,7 @@ use lib "$FindBin::Bin/lib";
use WebGUI::Test;
use WebGUI::Session;
use WebGUI::VersionTag;
use Test::More tests => 60; # increment this value for each test you create
use Test::More tests => 62; # increment this value for each test you create
my $session = WebGUI::Test->session;
@ -242,7 +242,25 @@ ok($adminSiteWideTag->getId() eq $siteWideTagId, 'versionTagMode siteWide + admi
$admin_session->var()->end();
$admin_session->close();
# Check if get returns a safe copy
my $name = $userTag->get( 'name' );
my $safeCopy = $userTag->get;
$safeCopy->{ name } = 'NotSoSafeAfterAll!';
is(
$userTag->get( 'name' ),
$name,
'get returns a safe copy of the internal data hash'
);
my $otherSafeCopy = $userTag->get;
isnt(
$safeCopy,
$otherSafeCopy,
'get returns unique safe copies on each invocation'
);
$userTag->rollback();
$siteWideTag->rollback();