Clear cache on assets in trash and clipboard limbo states. fixes bug #11027

This commit is contained in:
Colin Kuskie 2009-09-23 15:39:56 -07:00
parent 9a52044462
commit e4b99f1d6c
5 changed files with 91 additions and 34 deletions

View file

@ -54,6 +54,7 @@ sub canPaste {
=head2 cut ( )
Removes asset from lineage, places it in clipboard state. The "gap" in the lineage is changed in state to clipboard-limbo.
Return 1 if the cut was successful, otherwise it returns undef.
=cut
@ -65,9 +66,12 @@ sub cut {
$session->db->write("update asset set state='clipboard-limbo' where lineage like ? and state='published'",[$self->get("lineage").'%']);
$session->db->write("update asset set state='clipboard', stateChangedBy=?, stateChanged=? where assetId=?", [$session->user->userId, $session->datetime->time(), $self->getId]);
$session->db->commit;
$self->updateHistory("cut");
$self->{_properties}{state} = "clipboard";
$self->purgeCache;
foreach my $asset ($self, @{$self->getLineage(['descendants'], {returnObjects => 1})}) {
$asset->purgeCache;
$asset->updateHistory('cut');
}
return 1;
}

View file

@ -239,7 +239,8 @@ sub restore {
=head2 trash ( $options )
Removes asset from lineage, places it in trash state. The "gap" in the
lineage is changed in state to trash-limbo.
lineage is changed in state to trash-limbo. Returns 1 if the trash
was successful, otherwise it return undef.
=head3 $options
@ -264,9 +265,15 @@ sub trash {
return undef;
}
$outputSub->($i18n->get('Deleting exported files'));
foreach my $asset ($self, @{$self->getLineage(['descendants'], {returnObjects => 1})}) {
$outputSub->($i18n->get('Clearing search index'));
my $index = WebGUI::Search::Index->new($asset);
$index->delete;
$outputSub->($i18n->get('Deleting exported files'));
$asset->_invokeWorkflowOnExportedFiles($session->setting->get('trashWorkflow'), 1);
$outputSub->($i18n->get('Purging the cache'));
$asset->purgeCache;
$asset->updateHistory("trashed");
}
# Trash any shortcuts to this asset
@ -280,12 +287,6 @@ sub trash {
# Raw database work is more efficient than $asset->update
my $db = $session->db;
$db->beginTransaction;
my $sth = $db->read("select assetId from asset where lineage like ?",[$self->get("lineage").'%']);
$outputSub->($i18n->get('Clearing search index'));
while (my ($id) = $sth->array) {
$db->write("delete from assetIndex where assetId=?",[$id]);
}
$outputSub->($i18n->get('Clearing asset tables'));
$db->write("update asset set state='trash-limbo' where lineage like ?",[$self->get("lineage").'%']);
$db->write("update asset set state='trash', stateChangedBy=?, stateChanged=? where assetId=?",[$session->user->userId, $session->datetime->time(), $self->getId]);
@ -293,8 +294,7 @@ sub trash {
# Update ourselves since we didn't use update()
$self->{_properties}{state} = "trash";
$self->updateHistory("trashed");
$self->purgeCache;
return 1;
}
require WebGUI::Workflow::Activity::DeleteExportedFiles;