purgeCache also cleans up internally cached objects, _parent, _thread
This commit is contained in:
parent
dbac3e2ae7
commit
13d65d8b4a
3 changed files with 80 additions and 8 deletions
|
|
@ -2350,7 +2350,7 @@ sub publish {
|
||||||
|
|
||||||
=head2 purgeCache ( )
|
=head2 purgeCache ( )
|
||||||
|
|
||||||
Purges all cache entries associated with this asset.
|
Purges all cache entries associated with this asset, CHI, Session->stow and object caches
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
|
|
@ -2361,6 +2361,7 @@ sub purgeCache {
|
||||||
$stow->delete('assetClass');
|
$stow->delete('assetClass');
|
||||||
$stow->delete('assetRevision');
|
$stow->delete('assetRevision');
|
||||||
$self->session->cache->remove("asset".$self->getId.$self->revisionDate);
|
$self->session->cache->remove("asset".$self->getId.$self->revisionDate);
|
||||||
|
$self->{_parent};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -293,30 +293,23 @@ the parent thread.
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
override cut => sub {
|
override cut => sub {
|
||||||
warn "post's cut";
|
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
# Fetch the Thread and CS before cutting the asset.
|
# Fetch the Thread and CS before cutting the asset.
|
||||||
my $thread = $self->getThread;
|
my $thread = $self->getThread;
|
||||||
warn "got thread";
|
|
||||||
my $cs = $thread->getParent;
|
my $cs = $thread->getParent;
|
||||||
warn "got cs";
|
|
||||||
|
|
||||||
# Cut the asset
|
# Cut the asset
|
||||||
my $result = super();
|
my $result = super();
|
||||||
warn "called super";
|
|
||||||
|
|
||||||
# If a post is being cut update the thread reply count first
|
# If a post is being cut update the thread reply count first
|
||||||
if ($thread->getId ne $self->getId) {
|
if ($thread->getId ne $self->getId) {
|
||||||
warn "calling _fixReplyCount on thread";
|
|
||||||
$self->_fixReplyCount( $thread );
|
$self->_fixReplyCount( $thread );
|
||||||
}
|
}
|
||||||
|
|
||||||
# Update the CS reply count. This step is also necessary when a Post is cut since the Thread's incrementReplies
|
# Update the CS reply count. This step is also necessary when a Post is cut since the Thread's incrementReplies
|
||||||
# also calls the CS's incrementReplies, possibly with the wrong last post Id.
|
# also calls the CS's incrementReplies, possibly with the wrong last post Id.
|
||||||
warn "calling _fixReplyCount on cs";
|
|
||||||
$self->_fixReplyCount( $cs );
|
$self->_fixReplyCount( $cs );
|
||||||
warn "all should be well...?";
|
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
};
|
};
|
||||||
|
|
@ -790,6 +783,8 @@ sub getThread {
|
||||||
}
|
}
|
||||||
$self->{_thread} = WebGUI::Asset::Post::Thread->newById($self->session, $threadId);
|
$self->{_thread} = WebGUI::Asset::Post::Thread->newById($self->session, $threadId);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
}
|
||||||
return $self->{_thread};
|
return $self->{_thread};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1202,6 +1197,7 @@ override purgeCache => sub {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
$self->session->cache->remove("view_".$self->getThread->getId) if ($self->getThread);
|
$self->session->cache->remove("view_".$self->getThread->getId) if ($self->getThread);
|
||||||
super();
|
super();
|
||||||
|
delete $self->{_thread};
|
||||||
};
|
};
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
|
||||||
75
t/Asset/Post/committing.t
Normal file
75
t/Asset/Post/committing.t
Normal file
|
|
@ -0,0 +1,75 @@
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
# Please read the legal notices (docs/legal.txt) and the license
|
||||||
|
# (docs/license.txt) that came with this distribution before using
|
||||||
|
# this software.
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
# http://www.plainblack.com info@plainblack.com
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
## Test that committing a post works, and doesn't affect the parent thread.
|
||||||
|
|
||||||
|
use FindBin;
|
||||||
|
use strict;
|
||||||
|
use lib "$FindBin::Bin/../../lib";
|
||||||
|
use Test::More;
|
||||||
|
use WebGUI::Test;
|
||||||
|
use WebGUI::Session;
|
||||||
|
use WebGUI::Asset::Wobject::Collaboration;
|
||||||
|
use WebGUI::Asset::Post;
|
||||||
|
use WebGUI::Asset::Post::Thread;
|
||||||
|
|
||||||
|
my $session = WebGUI::Test->session;
|
||||||
|
|
||||||
|
# Do our work in the import node
|
||||||
|
my $node = WebGUI::Asset->getImportNode($session);
|
||||||
|
|
||||||
|
# Grab a named version tag
|
||||||
|
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||||
|
$versionTag->set({name=>"Collab setup"});
|
||||||
|
|
||||||
|
# Need to create a Collaboration system in which the post lives.
|
||||||
|
my @addArgs = ( undef, undef, { skipAutoCommitWorkflows => 1, skipNotification => 1 } );
|
||||||
|
|
||||||
|
my $collab = $node->addChild(
|
||||||
|
{
|
||||||
|
className => 'WebGUI::Asset::Wobject::Collaboration',
|
||||||
|
title => 'Test Collaboration',
|
||||||
|
},
|
||||||
|
@addArgs
|
||||||
|
);
|
||||||
|
|
||||||
|
# finally, add posts and threads to the collaboration system
|
||||||
|
|
||||||
|
my $first_thread = $collab->addChild(
|
||||||
|
{
|
||||||
|
className => 'WebGUI::Asset::Post::Thread',
|
||||||
|
title => 'Test Thread',
|
||||||
|
},
|
||||||
|
@addArgs
|
||||||
|
);
|
||||||
|
|
||||||
|
##Thread 1, Post 1 => t1p1
|
||||||
|
my $t1p1 = $first_thread->addChild(
|
||||||
|
{
|
||||||
|
className => 'WebGUI::Asset::Post',
|
||||||
|
title => 'Test Post',
|
||||||
|
},
|
||||||
|
@addArgs
|
||||||
|
);
|
||||||
|
|
||||||
|
$versionTag->commit();
|
||||||
|
WebGUI::Test->addToCleanup($versionTag);
|
||||||
|
|
||||||
|
foreach my $asset ($collab, $t1p1, $first_thread, ) {
|
||||||
|
$asset = $asset->cloneFromDb;
|
||||||
|
}
|
||||||
|
|
||||||
|
is $collab->getChildCount, 1, 'collab has correct number of children';
|
||||||
|
is $first_thread->status, 'approved', 'thread is approved';
|
||||||
|
is $t1p1->status, 'approved', 'post is approved';
|
||||||
|
|
||||||
|
done_testing;
|
||||||
|
|
||||||
|
#vim:ft=perl
|
||||||
Loading…
Add table
Add a link
Reference in a new issue