Band-aid fix for bad decache of icalFeeds, where it is not deserialized from JSON. Fixes bug #12139.

This commit is contained in:
Colin Kuskie 2011-05-30 11:34:43 -07:00
parent 444c006aae
commit c3652d12a9
3 changed files with 21 additions and 5 deletions

View file

@ -3,6 +3,7 @@
- fixed #12142: Copy fails on imported threads
- 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
7.10.17
- fixed: Forced to use a PayDriver even with a balance of 0 in the cart.

View file

@ -712,7 +712,8 @@ sub getFeed {
=head2 getFeeds ( )
Gets an arrayref of hashrefs of all the feeds attached to this calendar.
Gets an arrayref of hashrefs of all the feeds attached to this calendar. Since the icalFeeds
property does double duty as JSON and Perl, deserialize from JSON if it's not already perl.
TODO: Format lastUpdated into the user's time zone
@ -720,7 +721,10 @@ TODO: Format lastUpdated into the user's time zone
sub getFeeds {
my $self = shift;
return $self->get('icalFeeds');
my $feeds = $self->get('icalFeeds');
return $feeds if (ref $feeds);
$self->session->log->warn('improperly stored icalFeed in calendar assetId:'.$self->getId);
return JSON::from_json($feeds);
}
#----------------------------------------------------------------------------

View file

@ -57,7 +57,7 @@ use Data::Dumper;
use WebGUI::Asset::Wobject::Calendar;
use WebGUI::Asset::Event;
plan tests => 12 + scalar @icalWrapTests;
plan tests => 15 + scalar @icalWrapTests;
my $session = WebGUI::Test->session;
@ -302,8 +302,6 @@ addToCleanup($tag2);
is(scalar @{ $windowCal->getLineage(['children'])}, 17, 'added events to the window calendar');
diag "startDate: ". $windowStart->toDatabase;
diag "endDate: ". $windowEnd->toDatabase;
my @window = $windowCal->getEventsIn($windowStart->toDatabase, $windowEnd->toDatabase);
cmp_bag(
@ -595,3 +593,16 @@ cmp_deeply(
[],
'getFeeds: returns an empty array ref with no feeds'
);
##Update with JSON and try again :)
$feedCal->update({icalFeeds => '[]'});
is_deeply $feedCal->get('icalFeeds'), [], 'set as JSON, returned perl';
$feedCal->{_properties}->{icalFeeds} = '[]';
is $feedCal->get('icalFeeds'), '[]', 'poked into the object directly, returned as JSON';
cmp_deeply(
$feedCal->getFeeds(),
[],
'but getFeeds still returns a data structure.'
);