PluginProbe
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses / 2.11.0
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses v2.11.0
2.11.0 2.10.0 2.10.01 2.9.1 2.9.0 2.8.1 2.8.0 2.7.7 2.7.5 2.7.0 2.6.01 2.6.0 2.5.0 2.4.01 trunk 1.0.90 1.0.91 1.0.92 1.0.93 1.0.94 1.0.95 1.0.96 1.0.97 1.0.98 1.0.99 All 78 releases
← All changes | app/Http/Controllers/CommentsController.php +11 -3 2.10.012.11.0 View file →
@@ -144,10 +144,14 @@
144 144 return null;
145 145 }
146 146
147 147 $newComment = Comment::create($commentData);
148 - Feed::withoutGlobalScopes()->where('id', $feed->id)->increment('comments_count');
149 148
149 + // A held comment is not visible yet, so it must not be counted until it is approved.
150 + if ($newComment->status === 'published') {
151 + Feed::withoutGlobalScopes()->where('id', $feed->id)->increment('comments_count');
152 + }
153 +
150 154 return $newComment;
151 155 });
152 156
153 157 if (!$comment) {
@@ -155,9 +159,11 @@
155 159 'message' => __('No duplicate comment please!', 'fluent-community')
156 160 ]);
157 161 }
158 162
159 - $feed->comments_count = $feed->comments_count + 1;
163 + if ($comment->status === 'published') {
164 + $feed->comments_count = $feed->comments_count + 1;
165 + }
160 166
161 167
162 168 // Merge and save all media in one loop
163 169 $mediaItems = $mediaItems ? (is_array($mediaItems) ? $mediaItems : [$mediaItems]) : [];
@@ -613,9 +619,11 @@
613 619 }
614 620
615 621 $comment->delete();
616 622
617 - $feed->comments_count = Comment::where('post_id', $feed->id)->count();
623 + $feed->comments_count = Comment::where('post_id', $feed->id)
624 + ->where('status', 'published')
625 + ->count();
618 626 $feed->timestamps = false; // Don't update the updated_at timestamp
619 627 $feed->save();
620 628
621 629 do_action('fluent_community/comment_deleted_' . $feed->type, $commentId, $feed);