From fab70d71c7515038be781d1cffafc64bd3e0b152 Mon Sep 17 00:00:00 2001 From: Scott Walters Date: Sat, 27 Oct 2012 02:00:57 -0400 Subject: [PATCH] gracefully handle Collaborations having no lastPostId in the MessageBoard asset --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Asset/Wobject/MessageBoard.pm | 32 +++++++++++++----------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index d0e9cdce7..bf4dccfd4 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -15,6 +15,7 @@ - fixed #12384: Click and drag reordering does not work in IE9 - fixed: MessageBoard tolerates Collaboration children not yet having a value for lastPostId - on invalid proceed method in call to editSave, warn and recover rather than run time error + - gracefully handle Collaborations having no lastPostId in the MessageBoard asset 7.10.26 - fixed: Template diagnostics when called without a session asset. diff --git a/lib/WebGUI/Asset/Wobject/MessageBoard.pm b/lib/WebGUI/Asset/Wobject/MessageBoard.pm index 7e4ee95dd..1df99454e 100644 --- a/lib/WebGUI/Asset/Wobject/MessageBoard.pm +++ b/lib/WebGUI/Asset/Wobject/MessageBoard.pm @@ -129,21 +129,23 @@ sub view { $first = $child; } my %lastPostVars; - my $lastPost = WebGUI::Asset::Wobject::MessageBoard->newByDynamicClass($self->session, $child->get("lastPostId")); - if (defined $lastPost) { - %lastPostVars = ( - 'forum.lastPost.url' => $lastPost->getUrl, - 'forum.lastPost.date' => $self->session->datetime->epochToHuman($lastPost->get("creationDate"),"%z"), - 'forum.lastPost.time' => $self->session->datetime->epochToHuman($lastPost->get("creationDate"),"%Z"), - 'forum.lastPost.epoch' => $lastPost->get("creationDate"), - 'forum.lastPost.subject' => $lastPost->get("title"), - 'forum.lastPost.user.hasRead' => $lastPost->getThread->isMarkedRead, - 'forum.lastPost.user.id' => $lastPost->get("ownerUserId"), - 'forum.lastPost.user.name' => $lastPost->get("username"), - 'forum.lastPost.user.alias' => $lastPost->get("username"), - 'forum.lastPost.user.profile' => $lastPost->getPosterProfileUrl, - 'forum.lastPost.user.isVisitor' => ($lastPost->get("ownerUserId") eq '1') - ); + if( $child->get('lastPostId') ) { + my $lastPost = WebGUI::Asset::Wobject::MessageBoard->newByDynamicClass($self->session, $child->get("lastPostId")); + if (defined $lastPost) { + %lastPostVars = ( + 'forum.lastPost.url' => $lastPost->getUrl, + 'forum.lastPost.date' => $self->session->datetime->epochToHuman($lastPost->get("creationDate"),"%z"), + 'forum.lastPost.time' => $self->session->datetime->epochToHuman($lastPost->get("creationDate"),"%Z"), + 'forum.lastPost.epoch' => $lastPost->get("creationDate"), + 'forum.lastPost.subject' => $lastPost->get("title"), + 'forum.lastPost.user.hasRead' => $lastPost->getThread->isMarkedRead, + 'forum.lastPost.user.id' => $lastPost->get("ownerUserId"), + 'forum.lastPost.user.name' => $lastPost->get("username"), + 'forum.lastPost.user.alias' => $lastPost->get("username"), + 'forum.lastPost.user.profile' => $lastPost->getPosterProfileUrl, + 'forum.lastPost.user.isVisitor' => ($lastPost->get("ownerUserId") eq '1') + ); + } } push(@forum_loop, {