[3.0] Link the first page of a topic on the message index - #9453
Merged
live627 merged 1 commit intoAug 11, 2026
Merged
Conversation
A topic that runs to more than one page gets a little "Pages 1 2 3" index
beside it on the message index. Page 1 came out as plain text rather than a
link, so the first page of every multi-page topic was the one page you could
not click through to.
PageIndex has a branch for exactly this. A caller with no current page to
mark passes a negative start, fixStart() records that in $start_invalid, and
pageRange() then renders even the "current" page as a link:
// If start was invalid, show page number as a link to the proper start value.
if ($this->start_invalid) {
That branch has never run. __toString() calls fixStart() a second time,
because $this->start is public and may have been changed since. By then the
constructor has already clamped the caller's -1 to 0, so fixStart() looks at
0, decides the start is perfectly valid, and overwrites the verdict it
recorded the first time. $start_invalid is therefore false whenever it is
read.
Keeps the earlier verdict and lets the second look only add to it, so a
start that has gone negative since construction still counts.
MessageIndex::buildTopicContext() is the one caller that passes -1
deliberately. On a topic spanning three pages:
before <span class="pages">Pages</span><span class="current_page">1</span> <a ...>2</a> <a ...>3</a>
after <span class="pages">Pages</span><a href="...topic=1.0">1</a> <a ...>2</a> <a ...>3</a>
The board's own page index is unchanged - there the start really is 0 and
page 1 really is the current page.
Signed-off-by: Mathias Albert <mathiaspapealbert@hotmail.com>
Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
A topic that runs to more than one page gets a little
Pages 1 2 3index beside it on the message index. Page 1 comes out as plain text rather than a link, so the first page of every multi-page topic is the one page you cannot click through to.PageIndexhas a branch for exactly this case. A caller with no current page to mark passes a negative start,fixStart()records that in$start_invalid, andpageRange()then renders even the "current" page as a link:That branch has never run.
__toString()callsfixStart()a second time, reasonably enough —$this->startis public and may have been changed since construction:But
fixStart()does double duty: it clamps the value and records whether what it was given was negative. By the time__toString()runs, the constructor has already clamped the caller's-1to0, so the second call looks at0, decides the start is perfectly valid, and overwrites the verdict recorded the first time.$start_invalidis thereforefalseevery time it is read.The fix keeps the earlier verdict and lets the second look only add to it, so a start that has gone negative since construction still counts.
Effect
MessageIndex::buildTopicContext()is the one caller that passes-1deliberately. On a topic spanning three pages:<span class="current_page">1</span><a class="nav_page" href="…?topic=1.0">1</a>Pages 2 and 3 are unchanged, as is the
Pageslabel.The board's own page index is unchanged — there the start really is
0and page 1 really is the current page:#pages1)current_page.pagelinks)current_pagecurrent_pagecurrent_pagecurrent_pageThat last row is unchanged because the board URL parser clamps the start well before
PageIndexsees it, so this stays confined to callers that pass a negative start on purpose.Found while triaging the message index for #7933; it changes no template, so it goes on its own.
Issues References (Fixes|Related|Closes)
Related: #7933