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.
This commit is contained in:
Scott Walters 2010-08-09 15:17:00 -04:00
parent e43745cd86
commit 9eea40aeff

View file

@ -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 );
}
}
}