Fix photo JSON handling in the story, where the data is cached incorrectly. Fixes bug #12136
This commit is contained in:
parent
b872694390
commit
ab1b6aa4fd
3 changed files with 64 additions and 18 deletions
|
|
@ -5,6 +5,7 @@
|
|||
- canView will now be checked before calling ANY www_ method on account
|
||||
plugins to fix an Inbox security bug (and other similar potential bugs).
|
||||
- fixed #12139: break on calander feeds during upgrade
|
||||
- fixed #12136: Unable to add more than one image in Story
|
||||
|
||||
7.10.17
|
||||
- fixed: Forced to use a PayDriver even with a balance of 0 in the cart.
|
||||
|
|
|
|||
|
|
@ -21,8 +21,6 @@ use Tie::IxHash;
|
|||
use WebGUI::Utility;
|
||||
use WebGUI::International;
|
||||
use JSON qw/from_json to_json/;
|
||||
use Storable qw/dclone/;
|
||||
use Data::Dumper;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -70,15 +68,8 @@ sub addRevision {
|
|||
my $session = $self->session;
|
||||
my $newSelf = $self->next::method(@_);
|
||||
|
||||
my $newProperties = {
|
||||
isHidden => 1,
|
||||
};
|
||||
|
||||
$newSelf->update($newProperties);
|
||||
|
||||
my $newPhotoData = $newSelf->duplicatePhotoData;
|
||||
$newSelf->setPhotoData($newPhotoData);
|
||||
#$newSelf->requestAutoCommit;
|
||||
|
||||
return $newSelf;
|
||||
}
|
||||
|
|
@ -546,12 +537,10 @@ Returns the photo hash formatted as perl data. See also L<setPhotoData>.
|
|||
|
||||
sub getPhotoData {
|
||||
my $self = shift;
|
||||
if (!exists $self->{_photoData}) {
|
||||
my $json = $self->get('photo');
|
||||
$json ||= '[]';
|
||||
$self->{_photoData} = from_json($json);
|
||||
}
|
||||
return dclone($self->{_photoData});
|
||||
my $json = $self->get('photo');
|
||||
$json ||= '[]';
|
||||
my $photoData = from_json($json);
|
||||
return $photoData;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -803,7 +792,6 @@ sub setPhotoData {
|
|||
my $photo = to_json($photoData);
|
||||
##Update the db.
|
||||
$self->update({photo => $photo});
|
||||
delete $self->{_photoData};
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -864,7 +852,6 @@ Extend the superclass to make sure that the asset always stays hidden from navig
|
|||
sub update {
|
||||
my $self = shift;
|
||||
my $properties = shift;
|
||||
#$self->session->log->warn('story update');
|
||||
return $self->next::method({%$properties, isHidden => 1});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
# http://www.plainblack.com info@plainblack.com
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
use Test::MockTime qw/:all/;
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
|
|
@ -84,7 +86,7 @@ WebGUI::Test->addToCleanup($storage1, $storage2);
|
|||
#
|
||||
############################################################
|
||||
|
||||
my $tests = 47;
|
||||
my $tests = 49;
|
||||
plan tests => 1
|
||||
+ $tests
|
||||
+ $canEditMaker->plan
|
||||
|
|
@ -482,6 +484,62 @@ cmp_bag(
|
|||
) or diag Dumper( $keyword_loop );
|
||||
$session->scratch->delete('isExporting');
|
||||
|
||||
############################################################
|
||||
#
|
||||
# addRevision, copying and duplicating photo data
|
||||
#
|
||||
############################################################
|
||||
|
||||
set_relative_time(-70);
|
||||
|
||||
my $rev_story = $archive->addChild({
|
||||
className => 'WebGUI::Asset::Story',
|
||||
title => 'Story revision',
|
||||
subtitle => 'The story of a CMS',
|
||||
byline => 'C.F. Kuskie',
|
||||
story => 'Revisioning a story should not cause the photo information to be lost.',
|
||||
}, undef, undef, { skipAutoCommitWorkflows => 1, skipNotification => 1, });
|
||||
|
||||
my $tag = WebGUI::VersionTag->getWorking($session);
|
||||
$tag->commit;
|
||||
|
||||
my $rev_story = $rev_story->cloneFromDb;
|
||||
|
||||
my $rev_storage = WebGUI::Storage->create($session);
|
||||
|
||||
$rev_story->setPhotoData([{
|
||||
byLine => 'C Forest Kuskie',
|
||||
caption => 'ugly old hacker',
|
||||
storageId => $rev_storage->getId,
|
||||
}]);
|
||||
|
||||
cmp_deeply(
|
||||
$rev_story->getPhotoData,
|
||||
[{
|
||||
byLine => 'C Forest Kuskie',
|
||||
caption => 'ugly old hacker',
|
||||
storageId => $rev_storage->getId,
|
||||
}],
|
||||
'setup for add revision test, photo data'
|
||||
);
|
||||
|
||||
restore_time();
|
||||
|
||||
my $revision = $rev_story->addRevision({}, undef, undef, { skipAutoCommitWorkflows => 1, skipNotification => 1, });
|
||||
|
||||
cmp_deeply(
|
||||
$revision->getPhotoData,
|
||||
[{
|
||||
byLine => 'C Forest Kuskie',
|
||||
caption => 'ugly old hacker',
|
||||
storageId => ignore(),
|
||||
}],
|
||||
'revision has a copy of most of the photo data'
|
||||
);
|
||||
|
||||
my $revision_storageId = $revision->getPhotoData->[0]->{storageId};
|
||||
|
||||
ok($revision_storageId && ($revision_storageId ne $rev_storage->getId), 'storageId in the revision is different from the original');
|
||||
|
||||
}
|
||||
#vim:ft=perl
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue