From 9eea40aeff82c995124d3fb74a99e2655df55f7c Mon Sep 17 00:00:00 2001 From: Scott Walters Date: Mon, 9 Aug 2010 15:17:00 -0400 Subject: [PATCH] Don't blow up on view when there are no WebGUI::Asset::WikiPage child objects under us to feature. Also, the only reason that -1 on the rand works is because Perl is nice. --- lib/WebGUI/Asset/Wobject/WikiMaster.pm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/WebGUI/Asset/Wobject/WikiMaster.pm b/lib/WebGUI/Asset/Wobject/WikiMaster.pm index d9c962e9f..bc6e1ea5c 100644 --- a/lib/WebGUI/Asset/Wobject/WikiMaster.pm +++ b/lib/WebGUI/Asset/Wobject/WikiMaster.pm @@ -838,10 +838,13 @@ sub view { my $featuredIds = $self->getFeaturedPageIds; if( @$featuredIds ) { + # it's possible for a WikiMaster not to have any WikiPage featured; it's also possible for any to not render my $featuredId = $featuredIds->[ int( rand @$featuredIds ) - 1 ]; - my $featured = eval { WebGUI::Asset->newById( $session, $featuredId ) }; - if ( ! Exception::Class->caught() ) { - $self->appendFeaturedPageVars( $var, $featured ); + if( $featuredId ) { + my $featured = eval { WebGUI::Asset->newById( $session, $featuredId ) }; + if ( ! Exception::Class->caught() ) { + $self->appendFeaturedPageVars( $var, $featured ); + } } }