From 3d1ed2f83fa693bceb2278e60cd6be605cb9a7c9 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Wed, 19 Aug 2009 20:11:16 +0000 Subject: [PATCH] Make threads recalculate rating on delete/restore. Fixes #10788. --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Asset/Post.pm | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index dea584ba8..1a40df4c2 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -1,4 +1,5 @@ 7.7.18 + - fixed #10788: Thread rating calculate during post delete/restore - will now respect X-Forwarded-Proto header - no longer need special Apache configuration to handle SSLPROXY header - fixed #10674: CDN URLs are cached across HTTP/HTTPS accesses diff --git a/lib/WebGUI/Asset/Post.pm b/lib/WebGUI/Asset/Post.pm index 5c0e07150..ad8d9e113 100644 --- a/lib/WebGUI/Asset/Post.pm +++ b/lib/WebGUI/Asset/Post.pm @@ -1255,14 +1255,16 @@ sub recalculatePostRating { =head2 restore -Extend the base class to also make the thread containing this post to recalculate its replies +Extend the base class to also make the thread containing this post to recalculate its replies and +the thread rating. =cut sub restore { - my $self = shift; - $self->SUPER::restore(@_); - $self->getThread->sumReplies; + my $self = shift; + $self->SUPER::restore(@_); + $self->getThread->sumReplies; + $self->getThread->updateThreadRating; } @@ -1338,7 +1340,7 @@ sub setStatusUnarchived { =head2 trash ( ) -Moves post to the trash and updates reply counter on thread. +Moves post to the trash, updates reply counter on thread and recalculates the thread rating. =cut @@ -1346,6 +1348,7 @@ sub trash { my $self = shift; $self->SUPER::trash; $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