Uploaded image for project: 'phpBB3'
  1. phpBB3
  2. PHPBB3-10435

Topic count mismatch on viewforum

    Details

    • Type: Bug
    • Status: Unverified Fix
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.0.9
    • Fix Version/s: 3.0.10-RC1
    • Component/s: Viewing forums
    • Labels:
      None

      Description

      There is an inconsistency in topic_count between index and viewforum. I believe the one on index is correct, and the one in viewforum is not. I'll try to explain this through an example of one of my subforums, but this applies to all others which have topics with topic_type=2.

      I have a forum with forum_id=6. Query 'select count from phpbb_topics where forum_id=6;' responds with 100; manual topic count also provides 100 topics. Index page of phpbb forums also shows 100 in TOPICS column. But when I navigate to this forum, in a pagination block it shows "Topics: 99".

      There are no global announcements (topic_type=3) on the whole board. There is 1 announcement topic (topic_type=2) in this problematic subforum (forum_id=6). If I make another topic an announcement, topic count on viewtopic goes further down (to 98), which is obviously wrong.

      I've did some debugging and I've found the following code in viewforum.php:

      if ($row['topic_type'] == POST_GLOBAL)

      Unknown macro: { $global_announce_list[$row['topic_id']] = true; }

      else

      Unknown macro: { $topics_count--; }

      After this $topics_count--;, in my example, 100 becomes 99, to be shown on viewtopic later.

      I suppose this decrement is required to decrease the count of topics we will need to fetch later (because we already fetched announcements, we don't need to fetch em again), but we still need to sent $topic_count to the template before we make this decrement. It can be done like this:

      $template->assign_vars(array(
      'PAGINATION' => generate_pagination(append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . ((strlen($u_sort_param)) ? "&$u_sort_param" : '')), $topics_count, $config['topics_per_page'], $start),
      'PAGE_NUMBER' => on_page($topics_count, $config['topics_per_page'], $start)
      ));

      $topics_count+=count($announcement_list);

      $template->assign_vars(array(
      'TOTAL_TOPICS' => ($s_display_active) ? false : (($topics_count == 1) ? $user->lang['VIEW_FORUM_TOPIC'] : sprintf($user->lang['VIEW_FORUM_TOPICS'], $topics_count))
      ));

        Activity

        Hide
        nickvergessen Joas Schilling added a comment -

        Are there moved topics in that forum? And can you try, whether it helps to resync the topic counter for the forum? (ACP > Forums > Manage forums > yellow double arrow)

        Show
        nickvergessen Joas Schilling added a comment - Are there moved topics in that forum? And can you try, whether it helps to resync the topic counter for the forum? (ACP > Forums > Manage forums > yellow double arrow)
        Hide
        BioLogIn BioLogIn added a comment -

        There are no moved topics, and yes, I did resync multiple times. Also please read my description carefully, increasing number of announcement topics decreases topic count for viewtopic (not on index). It cannot possibly be a matter of resync and\or moved topics.

        Show
        BioLogIn BioLogIn added a comment - There are no moved topics, and yes, I did resync multiple times. Also please read my description carefully, increasing number of announcement topics decreases topic count for viewtopic (not on index). It cannot possibly be a matter of resync and\or moved topics.
        Hide
        BioLogIn BioLogIn added a comment - - edited

        Come on, just check YOUR forums. In your general discussion (http://www.phpbb.com/community/viewforum.php?f=6) there are 1720 topics, but only 1719 are shown on viewtopic.
        http://biologin.guiltygear.ru/phpbb_1.jpg
        http://biologin.guiltygear.ru/phpbb_2.jpg
        There is 1 announcement in this subforum

        Show
        BioLogIn BioLogIn added a comment - - edited Come on, just check YOUR forums. In your general discussion ( http://www.phpbb.com/community/viewforum.php?f=6 ) there are 1720 topics, but only 1719 are shown on viewtopic. http://biologin.guiltygear.ru/phpbb_1.jpg http://biologin.guiltygear.ru/phpbb_2.jpg There is 1 announcement in this subforum
        Show
        nickvergessen Joas Schilling added a comment - Fix for 3.0: https://github.com/phpbb/phpbb3/pull/458 Fix for 3.1: https://github.com/phpbb/phpbb3/pull/459

          People

          • Assignee:
            nickvergessen Joas Schilling
            Reporter:
            BioLogIn BioLogIn
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development