From 0bad1b2c46362eaa28f37b1914d4251e35ffc588 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E5=91=A8=E9=83=A8=E8=90=BD?= Date: Mon, 7 Feb 2022 13:44:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E6=B2=99=E5=8F=91?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E4=B8=8D=E5=8F=AF=E9=9D=A0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- upload/source/class/model/model_forum_post.php | 4 ---- upload/source/class/model/model_forum_thread.php | 3 +-- upload/source/function/function_forum.php | 4 ++++ upload/source/include/topicadmin/topicadmin_copy.php | 8 +++++++- upload/source/module/forum/forum_guide.php | 9 +++++++++ 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/upload/source/class/model/model_forum_post.php b/upload/source/class/model/model_forum_post.php index de244bfb6..59f9473e3 100644 --- a/upload/source/class/model/model_forum_post.php +++ b/upload/source/class/model/model_forum_post.php @@ -217,10 +217,6 @@ class model_forum_post extends discuz_model { dsetcookie('clearUserdata', 'forum'); - if($this->thread['replies'] <= 0) { - C::t('forum_sofa')->delete($this->thread['tid']); - } - if($this->param['modnewreplies']) { updatemoderate('pid', $this->pid); unset($this->param['showmsgparam']['pid']); diff --git a/upload/source/class/model/model_forum_thread.php b/upload/source/class/model/model_forum_thread.php index 834300014..4167ac411 100644 --- a/upload/source/class/model/model_forum_thread.php +++ b/upload/source/class/model/model_forum_thread.php @@ -142,6 +142,7 @@ class model_forum_thread extends discuz_model 'fid' => $this->forum['fid'], 'dateline' => $this->param['publishdate'], )); + C::t('forum_sofa')->insert(array('tid' => $this->tid,'fid' => $this->forum['fid'])); useractionlog($this->member['uid'], 'tid'); if(!getuserprofile('threads') && $this->setting['newbie']) { @@ -255,8 +256,6 @@ class model_forum_thread extends discuz_model updategroupcreditlog($this->forum['fid'], $this->member['uid']); } - C::t('forum_sofa')->insert(array('tid' => $this->tid,'fid' => $this->forum['fid'])); - return 'post_newthread_succeed'; } diff --git a/upload/source/function/function_forum.php b/upload/source/function/function_forum.php index 5b36e3db9..42f563f29 100644 --- a/upload/source/function/function_forum.php +++ b/upload/source/function/function_forum.php @@ -832,6 +832,10 @@ function insertpost($data) { if(isset($data['tid'])) { $thread = C::t('forum_thread')->fetch($data['tid']); $tableid = $thread['posttableid']; + // 第三方插件和系统内普遍直接用 insertpost 插入回复, 因此改为在这里处理 + if($thread['replies'] <= 0 && C::t('forum_sofa')->fetch($thread['tid'])) { + C::t('forum_sofa')->delete($thread['tid']); + } } else { $tableid = $data['tid'] = 0; } diff --git a/upload/source/include/topicadmin/topicadmin_copy.php b/upload/source/include/topicadmin/topicadmin_copy.php index bb64098eb..141232418 100644 --- a/upload/source/include/topicadmin/topicadmin_copy.php +++ b/upload/source/include/topicadmin/topicadmin_copy.php @@ -57,11 +57,17 @@ if(!submitcheck('modsubmit')) { $thread['posttableid'] = 0; $threadid = C::t('forum_thread')->insert($thread, true); + C::t('forum_newthread')->insert(array( + 'tid' => $threadid, + 'fid' => $thread['fid'], + 'dateline' => $thread['dateline'], + )); + C::t('forum_sofa')->insert(array('tid' => $threadid,'fid' => $thread['fid'])); if($post = C::t('forum_post')->fetch_threadpost_by_tid_invisible($_G['tid'])) { $post['pid'] = ''; $post['tid'] = $threadid; $post['fid'] = $copyto; - $post['dateline'] = TIMESTAMP; + $post['dateline'] = $thread['dateline']; $post['attachment'] = 0; $post['invisible'] = $post['rate'] = $post['ratetimes'] = 0; $post['message'] .= "\n".lang('forum/thread', 'source').": [url=forum.php?mod=viewthread&tid={$sourcetid}]{$thread['subject']}[/url]"; diff --git a/upload/source/module/forum/forum_guide.php b/upload/source/module/forum/forum_guide.php index 011a4f801..c9e8a95e4 100644 --- a/upload/source/module/forum/forum_guide.php +++ b/upload/source/module/forum/forum_guide.php @@ -134,6 +134,7 @@ function get_guide_list($view, $start = 0, $num = 50, $again = 0) { loadcache('forums'); $cachetimelimit = ($view != 'sofa') ? 900 : 60; $cache = $_G['cache']['forum_guide'][$view.($view=='sofa' && $_G['fid'] ? $_G['fid'] : '')]; + $notsofatids = array(); if($cache && (TIMESTAMP - $cache['cachetime']) < $cachetimelimit) { $tids = $cache['data']; $threadcount = count($tids); @@ -189,6 +190,11 @@ function get_guide_list($view, $start = 0, $num = 50, $again = 0) { if($thread['displayorder'] < 0) { continue; } + // 可能由于插件直接插入 post 等原因导致缓存表不符合实际情况, 这里对于不符合实际情况的数据做清理 + if($view == 'sofa' && $thread['replies'] > 0) { + $notsofatids[] = $thread['tid']; + continue; + } $thread = guide_procthread($thread); $threadids[] = $thread['tid']; if($tids || ($n >= $start && $n < ($start + $num))) { @@ -222,6 +228,9 @@ function get_guide_list($view, $start = 0, $num = 50, $again = 0) { $data = array('cachetime' => TIMESTAMP, 'data' => $threadids); $_G['cache']['forum_guide'][$view.($view=='sofa' && $_G['fid'] ? $_G['fid'] : '')] = $data; savecache('forum_guide', $_G['cache']['forum_guide']); + if(!empty($notsofatids)) { + C::t('forum_sofa')->delete($notsofatids); + } } return array('forumnames' => $forumnames, 'threadcount' => $threadcount, 'threadlist' => $threadlist); } -- Gitee