fixed bug where shortcuts weren't purged along with assets when both were in the trash
This commit is contained in:
parent
4583ce14fb
commit
4d22e7bcd6
3 changed files with 42 additions and 24 deletions
|
|
@ -1288,6 +1288,8 @@ sub getShortcutsForAssetId {
|
||||||
|
|
||||||
$properties->{ joinClass } = 'WebGUI::Asset::Shortcut';
|
$properties->{ joinClass } = 'WebGUI::Asset::Shortcut';
|
||||||
$properties->{ whereClause } = 'Shortcut.shortcutToAssetId = ' . $db->quote($assetId);
|
$properties->{ whereClause } = 'Shortcut.shortcutToAssetId = ' . $db->quote($assetId);
|
||||||
|
$properties->{ statesToInclude } = ['published', 'trash', 'clipboard', 'clipboard-limbo', 'trash-limbo'];
|
||||||
|
$properties->{ statusToInclude } = ['approved', 'pending', 'archived'];
|
||||||
|
|
||||||
return WebGUI::Asset->getRoot($session)->getLineage(['descendants'], $properties);
|
return WebGUI::Asset->getRoot($session)->getLineage(['descendants'], $properties);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,7 @@ sub purge {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Delete shortcuts to this asset
|
# Delete shortcuts to this asset
|
||||||
# Also publish any shortcuts to this asset that are in the trash
|
# Also purge any shortcuts to this asset that are in the trash
|
||||||
$outputSub->($i18n->get('Purging shortcuts'));
|
$outputSub->($i18n->get('Purging shortcuts'));
|
||||||
my $shortcuts
|
my $shortcuts
|
||||||
= WebGUI::Asset::Shortcut->getShortcutsForAssetId($self->session, $self->getId, {
|
= WebGUI::Asset::Shortcut->getShortcutsForAssetId($self->session, $self->getId, {
|
||||||
|
|
|
||||||
|
|
@ -29,17 +29,9 @@ my $node = WebGUI::Asset->getImportNode($session);
|
||||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||||
$versionTag->set({name=>"Shortcut Test"});
|
$versionTag->set({name=>"Shortcut Test"});
|
||||||
|
|
||||||
# Make a snippet to shortcut
|
my $snippet;
|
||||||
my $snippet
|
my $shortcut;
|
||||||
= $node->addChild({
|
init();
|
||||||
className => "WebGUI::Asset::Snippet",
|
|
||||||
});
|
|
||||||
|
|
||||||
my $shortcut
|
|
||||||
= $node->addChild({
|
|
||||||
className => "WebGUI::Asset::Shortcut",
|
|
||||||
shortcutToAssetId => $snippet->getId,
|
|
||||||
});
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Cleanup
|
# Cleanup
|
||||||
|
|
@ -50,7 +42,7 @@ END {
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Tests
|
# Tests
|
||||||
plan tests => 10;
|
plan tests => 11;
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Test shortcut's link to original asset
|
# Test shortcut's link to original asset
|
||||||
|
|
@ -126,21 +118,28 @@ eval {
|
||||||
|
|
||||||
is(
|
is(
|
||||||
$contentLastModified, 0,
|
$contentLastModified, 0,
|
||||||
"Purged Linked Asset: getContentLastModified returns 0",
|
"Purged Linked Asset: getContentLastModified returns 0 when linked asset missing",
|
||||||
);
|
);
|
||||||
|
|
||||||
# re-init so further tests will work
|
# re-init so further tests will work
|
||||||
$snippet
|
init();
|
||||||
= $node->addChild({
|
|
||||||
className => "WebGUI::Asset::Snippet",
|
|
||||||
});
|
|
||||||
|
|
||||||
$shortcut
|
#----------------------------------------------------------------------------
|
||||||
= $node->addChild({
|
# Test purging snippet purges shortcut also, even when they're both in the trash
|
||||||
className => "WebGUI::Asset::Shortcut",
|
|
||||||
shortcutToAssetId => $snippet->getId,
|
|
||||||
});
|
|
||||||
|
|
||||||
|
# This will trash both the snippet and the shortcut (or else an earlier test failed)
|
||||||
|
$snippet->trash();
|
||||||
|
|
||||||
|
$snippet->purge();
|
||||||
|
$shortcut = WebGUI::Asset->newByDynamicClass($session, $shortcut->getId);
|
||||||
|
|
||||||
|
ok(
|
||||||
|
!defined $shortcut,
|
||||||
|
"Purge Linked Asset: Shortcut is purged even though it's in the trash"
|
||||||
|
);
|
||||||
|
|
||||||
|
# re-init so further tests will work
|
||||||
|
init();
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Test purging snippet purges shortcut also
|
# Test purging snippet purges shortcut also
|
||||||
|
|
@ -150,4 +149,21 @@ $shortcut = WebGUI::Asset->newByDynamicClass($session, $shortcut->getId);
|
||||||
ok(
|
ok(
|
||||||
!defined $shortcut,
|
!defined $shortcut,
|
||||||
"Purge Linked Asset: Shortcut is not defined",
|
"Purge Linked Asset: Shortcut is not defined",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
# init a new snippet and shortcut; handy to have in a sub because we destroy
|
||||||
|
# them in some tests and need to reset them for the next round
|
||||||
|
sub init {
|
||||||
|
# Make a snippet to shortcut
|
||||||
|
$snippet
|
||||||
|
= $node->addChild({
|
||||||
|
className => "WebGUI::Asset::Snippet",
|
||||||
|
});
|
||||||
|
|
||||||
|
$shortcut
|
||||||
|
= $node->addChild({
|
||||||
|
className => "WebGUI::Asset::Shortcut",
|
||||||
|
shortcutToAssetId => $snippet->getId,
|
||||||
|
});
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue