From d57d9ff962b4de920d0e15621700f7843c24e01b 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 | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/WebGUI/Asset/Wobject/WikiMaster.pm b/lib/WebGUI/Asset/Wobject/WikiMaster.pm index f52eb94c2..3abc9f7ac 100644 --- a/lib/WebGUI/Asset/Wobject/WikiMaster.pm +++ b/lib/WebGUI/Asset/Wobject/WikiMaster.pm @@ -836,10 +836,13 @@ sub view { # Get a random featured page my $featuredIds = $self->getFeaturedPageIds; - my $featuredId = $featuredIds->[ int( rand @$featuredIds ) - 1 ]; - my $featured = WebGUI::Asset->newById( $session, $featuredId ); - if ( $featured ) { - $self->appendFeaturedPageVars( $var, $featured ); + + if( @$featuredIds ) { + my $featuredId = $featuredIds->[ int( rand @$featuredIds ) - 1 ]; + my $featured = WebGUI::Asset->newById( $session, $featuredId ); + if ( $featured ) { + $self->appendFeaturedPageVars( $var, $featured ); + } } $self->appendSearchBoxVars($var);