Uploaded image for project: 'phpBB'
  1. phpBB
  2. PHPBB-10435

Topic count mismatch on viewforum

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 3.0.10-RC1
    • 3.0.9
    • Viewing forums
    • None

      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))
      ));

            nickvergessen Joas Schilling
            BioLogIn BioLogIn [X] (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: