Преглед изворни кода

Update Forum\CalcStat()

For last_poster_id.
Visman пре 4 година
родитељ
комит
24f1ec4285
1 измењених фајлова са 13 додато и 11 уклоњено
  1. 13 11
      app/Models/Forum/CalcStat.php

+ 13 - 11
app/Models/Forum/CalcStat.php

@@ -5,13 +5,13 @@ declare(strict_types=1);
 namespace ForkBB\Models\Forum;
 
 use ForkBB\Models\Method;
-use RuntimeException;
 use ForkBB\Models\Forum\Model as Forum;
+use RuntimeException;
 
 class CalcStat extends Method
 {
     /**
-     * Пересчитывает статистику
+     * Пересчитывает статистику раздела
      */
     public function calcStat(): Forum
     {
@@ -35,7 +35,7 @@ class CalcStat extends Method
         $this->model->num_topics = $result['num_topics'] + $moved;
         $this->model->num_posts  = $result['num_topics'] + $result['num_replies'];
 
-        $query = 'SELECT t.last_post, t.last_post_id, t.last_poster, t.subject as last_topic
+        $query = 'SELECT t.last_post, t.last_post_id, t.last_poster, t.last_poster_id, t.subject as last_topic
             FROM ::topics AS t
             WHERE t.forum_id=?i:fid AND t.moved_to=0
             ORDER BY t.last_post DESC
@@ -44,15 +44,17 @@ class CalcStat extends Method
         $result = $this->c->DB->query($query, $vars)->fetch();
 
         if (empty($result)) {
-            $this->model->last_post    = 0;
-            $this->model->last_post_id = 0;
-            $this->model->last_poster  = 0;
-            $this->model->last_topic   = 0;
+            $this->model->last_post      = 0;
+            $this->model->last_post_id   = 0;
+            $this->model->last_poster    = 0;
+            $this->model->last_poster_id = 0
+            $this->model->last_topic     = 0;
         } else {
-            $this->model->last_post    = $result['last_post'];
-            $this->model->last_post_id = $result['last_post_id'];
-            $this->model->last_poster  = $result['last_poster'];
-            $this->model->last_topic   = $result['last_topic'];
+            $this->model->last_post      = $result['last_post'];
+            $this->model->last_post_id   = $result['last_post_id'];
+            $this->model->last_poster    = $result['last_poster'];
+            $this->model->last_poster_id = $result['last_poster_id'];
+            $this->model->last_topic     = $result['last_topic'];
         }
 
         return $this->model;