Skip to content

Count "show all pages" topics after the forum list is built - #206

Merged
avandenberghe merged 1 commit into
develop33from
issue-195-topic-count-forum-list
Oct 4, 2026
Merged

avandenberghe merged 1 commit into
develop33from
issue-195-topic-count-forum-list

Conversation

@avandenberghe

Copy link
Copy Markdown
Collaborator

Closes #195.

Problem
With "Show all recent topic pages" (rt_page_number) on, display_recent_topics() ran the count that sets total_topics_limit before get_forum_list(). $this->forum_ids was still null, so get_forums_visibility_sql() reduced the count to forums where the user has m_approve. That gave 0 for most users. For a moderator it gave a count of only their moderated forums, which then truncated the list and broke the pagination.

Fix
core/recenttopics.php: the count now runs after get_forum_list() and its "no forums" early return. The sort-order setup moved up with get_forum_list(), since get_allowed_topics_sql() reads it. Nothing else changed.

Tests

  • New tests/core/topic_count_test.php, documented in tests/tests.md. It runs display_recent_topics() with "show all pages" on and checks that every topic query is scoped to the user's forum list. Before the fix the count query received an empty list (failed); after, it passes.
  • Unit suite: 45 tests, 0 failures, run locally. The functional tests run in CI.

Checked on the local board (boot script, rt_page_number switched on in memory only):

User RT forums page-count limit, before page-count limit, after approved topics in those forums
Anonymous 32 0 935 935
admin 52 0 2091 2091

No changelog entry or version bump, per this repo's convention.

🤖 Generated with Claude Code

With rt_page_number on, display_recent_topics() ran the topic count
that sets total_topics_limit before get_forum_list(). forum_ids was
still null, so get_forums_visibility_sql() reduced the count to forums
where the user has m_approve: 0 for most users, and a count of only
their moderated forums for a moderator, which then truncated the list
and broke the pagination.

Run the count after get_forum_list() and its empty-list return. The
sort order is set before both, as get_allowed_topics_sql() reads it.

Closes #195

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@avandenberghe
avandenberghe merged commit 810dfba into develop33 Oct 4, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Show all recent topic pages" computes topic count before the forum list is built

1 participant