Summary
In core/recenttopics.php, when rt_page_number ("Show all recent topic pages") is enabled, total_topics_limit is computed via get_allowed_topics_sql() (which builds its WHERE clause from $this->forum_ids, through content_visibility::get_forums_visibility_sql()) before get_forum_list() has run. At that point $this->forum_ids is still unset/null.
content_visibility::get_forums_visibility_sql() combines two branches with OR:
- moderator-approve forums:
forum_id IN (approve_forums)
- normal-read forums:
topic_visibility = APPROVED AND forum_id IN ($forum_ids)
With $forum_ids empty/null, sql_in_set(..., array(), false, true) collapses the normal-read branch to false, so the count query silently degrades to "only forums where the user has m_approve". For a normal member (no m_approve anywhere) the count comes back 0 or matches no forums; for a moderator it returns a count scoped only to their moderated forums — unrelated to the actual Recent Topics forum set.
That wrong total_topics_limit then drives pagination, so page 1 is marked current on every page and the list renders truncated to this unrelated count.
Location
avathar/recenttopics/core/recenttopics.php:
total_topics_limit computed around line 338-353, calling get_allowed_topics_sql() (which reads $this->forum_ids at line ~640 via get_forums_visibility_sql())
get_forum_list() (which populates $this->forum_ids) is not called until line 362 — after the count above
Steps to reproduce
- Enable "Show all recent topic pages" (
rt_page_number).
- Log in as a moderator with
m_approve on some forum(s) but not all forums the Recent Topics block would otherwise draw from.
- View the Recent Topics list: the topic count / pagination reflects only the moderated forum(s), not the full set of readable forums, and page 1 is marked current regardless of the actual page shown.
Fix
Move the total_topics_limit computation after get_forum_list(), or reuse the topic count already produced inside get_topic_list() instead of running a second, separately-scoped count query beforehand.
Summary
In
core/recenttopics.php, whenrt_page_number("Show all recent topic pages") is enabled,total_topics_limitis computed viaget_allowed_topics_sql()(which builds its WHERE clause from$this->forum_ids, throughcontent_visibility::get_forums_visibility_sql()) beforeget_forum_list()has run. At that point$this->forum_idsis still unset/null.content_visibility::get_forums_visibility_sql()combines two branches with OR:forum_id IN (approve_forums)topic_visibility = APPROVED AND forum_id IN ($forum_ids)With
$forum_idsempty/null,sql_in_set(..., array(), false, true)collapses the normal-read branch to false, so the count query silently degrades to "only forums where the user hasm_approve". For a normal member (nom_approveanywhere) the count comes back 0 or matches no forums; for a moderator it returns a count scoped only to their moderated forums — unrelated to the actual Recent Topics forum set.That wrong
total_topics_limitthen drives pagination, so page 1 is marked current on every page and the list renders truncated to this unrelated count.Location
avathar/recenttopics/core/recenttopics.php:total_topics_limitcomputed around line 338-353, callingget_allowed_topics_sql()(which reads$this->forum_idsat line ~640 viaget_forums_visibility_sql())get_forum_list()(which populates$this->forum_ids) is not called until line 362 — after the count aboveSteps to reproduce
rt_page_number).m_approveon some forum(s) but not all forums the Recent Topics block would otherwise draw from.Fix
Move the
total_topics_limitcomputation afterget_forum_list(), or reuse the topic count already produced insideget_topic_list()instead of running a second, separately-scoped count query beforehand.