【注意】:
当前修正方法还没有进行全面的测试,慎用。本人只做一个临时记录,后续问题可能等待适当时间进行处理。
未测试内容: 特殊主题是否正常;抢楼贴是否正常;其他未知方面...
【修正:】
2013/07/16 修正修改时导致正序出现问题的Bug。修正代码参见下面的代码。
将下述代码:- $startLimit = $page > 1 ? ($_G['forum_pagebydesc'] ? $start_limit + 1 : $start_limit - 1) : $start_limit;
- $gppp = $page > 1 ? $_G['ppp'] : $_G['ppp'] - 1;
复制代码 替换为:- $startLimit = ($page > 1 && $ordertype == 1) ? ($_G['forum_pagebydesc'] ? $start_limit + 1 : $start_limit - 1) : $start_limit;
- $gppp = ($page == 1 && $ordertype == 1) ? $_G['ppp'] - 1 : $_G['ppp'];
复制代码 即可
当论坛某主题的帖子出现删帖时,我们往往会看到“无效楼层,帖子可能已删除”的提示(也可能进入未审核)。当论坛浏览时检测到这种现象,帖子tid将被记录到一个名为“forum_threaddisablepos”的数据表中,此时如果该帖不是抢楼贴的话 $disablepos 将生效,同时按照 position 获取帖子将被禁止,导致 $maxposition 为 false。
在这种情况下,当倒序浏览帖子的时候,会发现以下问题:
1. 楼主贴楼层序号变为 #,而不是楼主;
2. 第一页有 11 个帖子,最后一页少一个帖子;如果最后一页只有1个帖子的时候,会导致“没有帖子”的错误提示
3. 如果只有一页的话,最后一个会变成 楼主
上述问题在 x2.5 和 x3 中均有出现。
临时修正方案:
第一步:
找到以下代码,位置大概在文件的 560行上下- if(!$maxposition && empty($postarr)) {
- if(empty($_GET['viewpid'])) {
-
- if($_G['forum_thread']['special'] == 2) {
- $postarr = C::t('forum_post')->fetch_all_tradepost_viewthread_by_tid($_G['tid'], $visibleallflag, $_GET['authorid'], $tpids, $_G['forum_pagebydesc'], $ordertype, $start_limit, ($_G['forum_pagebydesc'] ? $_G['forum_ppp2'] : $_G['ppp']));
- } elseif($_G['forum_thread']['special'] == 5) {
- $postarr = C::t('forum_post')->fetch_all_debatepost_viewthread_by_tid($_G['tid'], $visibleallflag, $_GET['authorid'], $_GET['stand'], $_G['forum_pagebydesc'], $ordertype, $start_limit, ($_G['forum_pagebydesc'] ? $_G['forum_ppp2'] : $_G['ppp']));
- } else {
- $postarr = C::t('forum_post')->fetch_all_common_viewthread_by_tid($_G['tid'], $visibleallflag, $_GET['authorid'], $_G['forum_pagebydesc'], $ordertype, $_G['forum_thread']['replies'] + 1, $start_limit, ($_G['forum_pagebydesc'] ? $_G['forum_ppp2'] : $_G['ppp']));
- }
- } else {
复制代码 修改为:- if(!$maxposition && empty($postarr)) {
- if(empty($_GET['viewpid'])) {
- //$startLimit = $page > 1 ? ($_G['forum_pagebydesc'] ? $start_limit + 1 : $start_limit - 1) : $start_limit;
- //$gppp = $page > 1 ? $_G['ppp'] : $_G['ppp'] - 1;
- $startLimit = ($page > 1 && $ordertype == 1) ? ($_G['forum_pagebydesc'] ? $start_limit + 1 : $start_limit - 1) : $start_limit;
- $gppp = ($page == 1 && $ordertype == 1) ? $_G['ppp'] - 1 : $_G['ppp'];
-
- if($_G['forum_thread']['special'] == 2) {
- $postarr = C::t('forum_post')->fetch_all_tradepost_viewthread_by_tid($_G['tid'], $visibleallflag, $_GET['authorid'], $tpids, $_G['forum_pagebydesc'], $ordertype, $startLimit, ($_G['forum_pagebydesc'] ? $_G['forum_ppp2'] : $gppp));
- } elseif($_G['forum_thread']['special'] == 5) {
- $postarr = C::t('forum_post')->fetch_all_debatepost_viewthread_by_tid($_G['tid'], $visibleallflag, $_GET['authorid'], $_GET['stand'], $_G['forum_pagebydesc'], $ordertype, $startLimit, ($_G['forum_pagebydesc'] ? $_G['forum_ppp2'] : $gppp));
- } else {
- $postarr = C::t('forum_post')->fetch_all_common_viewthread_by_tid($_G['tid'], $visibleallflag, $_GET['authorid'], $_G['forum_pagebydesc'], $ordertype, $_G['forum_thread']['replies'] + 1, $startLimit, ($_G['forum_pagebydesc'] ? $_G['forum_ppp2'] : $gppp));
- }
- } else {
复制代码 此处做了两件事:
1 修正 gpp
2 修正开始查询的位置
修改理由:
第一页因为有楼主帖子存在,所以在倒序获取回复时应该只获取9个,而不是10个,所以 $gppp 为 $_G['ppp'] - 1,之后恢复正常。
第二页开始偏移位置应该往前移动1个,所以-1;而当页数达到总页数的一半以上时,回复获取为ASC,需要将偏移值增加1。
第二处修正为 number 值的修正,代码位置大概在 1060~1080行,需要修改的行在 1070上下,有两处(下面的代码只有一段,包含修改,请对比注释掉的行和新增加的行对比):- if(!$post['hotrecommended']) {
- if($_G['forum_pagebydesc']) {
- if($ordertype != 1) {
- $post['number'] = $_G['forum_numpost'] + $_G['forum_ppp2']--;
- } else {
- //$post['number'] = $post['first'] == 1 ? 1 : ($_G['forum_numpost'] - 1) - $_G['forum_ppp2']--;
- $post['number'] = $post['first'] == 1 ? 1 : ($_G['forum_numpost']) - $_G['forum_ppp2']--;
- }
- } else {
- if($ordertype != 1) {
- $post['number'] = ++$_G['forum_numpost'];
- } else {
- $post['number'] = $post['first'] == 1 ? 1 : --$_G['forum_numpost'];
- //$post['number'] = $post['number'] - 1;
- }
- }
- }
复制代码 此处的修改目的是,取消所有的楼层 number 减1,因为本身是不需要的。
|