diff --git a/lib/WebGUI/Asset/Post/Thread.pm b/lib/WebGUI/Asset/Post/Thread.pm index 1a6f11821..94dff5ba7 100644 --- a/lib/WebGUI/Asset/Post/Thread.pm +++ b/lib/WebGUI/Asset/Post/Thread.pm @@ -410,12 +410,12 @@ Fetches the last post in this thread, otherwise, returns itself. sub getLastPost { my $self = shift; my $lastPostId = $self->lastPostId; - my $lastPost; - if ($lastPostId) { - $lastPost = WebGUI::Asset::Post->newById($self->session, $lastPostId); - } - return $lastPost if (defined $lastPost); - return $self; + return $self unless $lastPostId; + my $lastPost = eval { WebGUI::Asset->newById($self->session, $lastPostId); }; + if (Exception::Class->caught()) { + return $self; + } + return $lastPost; } #------------------------------------------------------------------- diff --git a/t/Asset/Wobject/Collaboration/templateVariables.t b/t/Asset/Wobject/Collaboration/templateVariables.t index e151cec43..10ff8a086 100644 --- a/t/Asset/Wobject/Collaboration/templateVariables.t +++ b/t/Asset/Wobject/Collaboration/templateVariables.t @@ -89,7 +89,7 @@ ok( !$posts->[0]->{'user.isVisitor'}, 'first post made by visitor'); ok( $posts->[0]->{'hideProfileUrl'}, 'hide profile url, and user is visitor'); ok( !$posts->[0]->{'lastReply.user.isVisitor'}, 'lastReply not made by visitor'); ok( $posts->[0]->{'lastReply.hideProfileUrl'}, 'lastReply hide profile url, since user is visitor'); -is( $posts->[0]->{'lastReply.url'}, $threads[1]->getUrl.'?pn=1#id'.$threads[1]->getId, 'lastReply url has a query fragment prefixed by "id"'); +is( $posts->[0]->{'lastReply.url'}, $threads[1]->getUrl.'#id'.$threads[1]->getId, 'lastReply url has a query fragment prefixed by "id"'); is( $posts->[0]->{'url'}, $threads[1]->getUrl.'#id'.$threads[1]->getId, 'url has a query fragment prefixed by "id"');