Add tests for printableStyleTemplateId.

Found a fixed an infinite loop in WebGUI::Style::process

If an asset was requested to be printed who does not have a
printableStyleTemplateId then process would recurse back up the
lineage until it does find an asset with a printableStyleTemplateId.
Eventually, if none is found, it will find the Asset Root, whose
parent is itself, and it will loop forever.

I added code to jump out of the loop if it recurses back to the
assetRoot.
This commit is contained in:
Colin Kuskie 2006-10-12 04:06:13 +00:00
parent 57f7fe1c6f
commit 01a09cbea9
2 changed files with 90 additions and 6 deletions

View file

@ -160,10 +160,12 @@ sub process {
if ($self->{_makePrintable} && $self->session->asset) {
$templateId = $self->{_printableStyleId} || $self->session->asset->get("printableStyleTemplateId");
my $currAsset = $self->session->asset;
until ($templateId) {
my $rootAssetId = WebGUI::Asset->getRoot($self->session)->getId;
TEMPLATE: until ($templateId) {
# some assets don't have this property. But at least one ancestor should....
$currAsset = $currAsset->getParent;
$templateId = $currAsset->get("printableStyleTemplateId");
last TEMPLATE if $currAsset->getId eq $rootAssetId;
}
} elsif ($self->session->scratch->get("personalStyleId") ne "") {
$templateId = $self->session->scratch->get("personalStyleId");