Correctly handle the case of finding new lastPost information when a Post is trashed. Fixes bug #11646.
This commit is contained in:
parent
54c56019d1
commit
05610f7621
4 changed files with 141 additions and 20 deletions
|
|
@ -1189,6 +1189,22 @@ sub postProcess {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 publish
|
||||
|
||||
Extend the base method to handle updating last post information in the parent Thread
|
||||
and CS.
|
||||
|
||||
=cut
|
||||
|
||||
sub publish {
|
||||
my $self = shift;
|
||||
$self->next::method(@_);
|
||||
$self->qualifyAsLastPost;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 purge
|
||||
|
||||
Extend the base method to handle cleaning up storage locations.
|
||||
|
|
@ -1398,7 +1414,8 @@ sub setStatusUnarchived {
|
|||
|
||||
=head2 trash ( )
|
||||
|
||||
Moves post to the trash, updates reply counter on thread and recalculates the thread rating.
|
||||
Moves post to the trash, updates reply counter on thread, recalculates the thread rating,
|
||||
and updates any lastPost information in the parent Thread, and CS.
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -1407,20 +1424,7 @@ sub trash {
|
|||
$self->next::method;
|
||||
$self->getThread->sumReplies if ($self->isReply);
|
||||
$self->getThread->updateThreadRating;
|
||||
if ($self->getThread->get("lastPostId") eq $self->getId) {
|
||||
my $threadLineage = $self->getThread->get("lineage");
|
||||
my ($id, $date) = $self->session->db->quickArray("select assetId, creationDate from asset where
|
||||
lineage like ? and assetId<>? and asset.state='published' and className like 'WebGUI::Asset::Post%'
|
||||
order by creationDate desc",[$threadLineage.'%', $self->getId]);
|
||||
$self->getThread->update({lastPostId=>$id, lastPostDate=>$date});
|
||||
}
|
||||
if ($self->getThread->getParent->get("lastPostId") eq $self->getId) {
|
||||
my $forumLineage = $self->getThread->getParent->get("lineage");
|
||||
my ($id, $date) = $self->session->db->quickArray("select assetId, creationDate from asset where
|
||||
lineage like ? and assetId<>? and asset.state='published' and className like 'WebGUI::Asset::Post%'
|
||||
order by creationDate desc",[$forumLineage.'%', $self->getId]);
|
||||
$self->getThread->getParent->update({lastPostId=>$id, lastPostDate=>$date});
|
||||
}
|
||||
$self->disqualifyAsLastPost;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue