Skip to content

[2.1] Lists the posts to split off a topic in a defined order - #9758

Merged
jdarwood007 merged 1 commit into
SimpleMachines:release-2.1from
albertlast:2.1/split-topic-message-order
Oct 31, 2026
Merged

jdarwood007 merged 1 commit into
SimpleMachines:release-2.1from
albertlast:2.1/split-topic-message-order

Conversation

@albertlast

Copy link
Copy Markdown
Collaborator

Description

Backport of #9714.

The page for choosing which posts to split off a topic lists them in no defined order on PostgreSQL. All four queries in SplitSelectTopics() (the selected and not-selected lists, each in the page and in its xml refresh) only added ORDER BY for members who view topics newest first:

' . (empty($options['view_newest_first']) ? '' : 'ORDER BY id_msg DESC') . '

Otherwise the order was up to the database. MySQL happens to return InnoDB rows in primary key order. PostgreSQL returns them in the order they are stored, and an UPDATE writes the row's new version at the end, so an edited post is listed after the posts that came after it. The same queries use LIMIT, so the order also decides which posts land on which page: a post can appear on two pages and be missing from another.

They now always order by message id, descending for members who view newest first:

ORDER BY id_msg' . (empty($options['view_newest_first']) ? '' : ' DESC') . '

Testing

Checked on a freshly installed release-2.1 forum on PostgreSQL 17, with a topic of three posts (4, 5, 6) whose first post was then edited in the database:

not selected after moving 6 and 4 across
before 5, 6, 4 selected: 6, 4
after 4, 5, 6 selected: 4, 6
after, newest first 6, 5, 4 selected: 6, 4

MySQL showed the right order before and after, as expected. Nothing in log_errors.

Issues References (Fixes|Related|Closes)

Related: #9753, #9714

🤖 Generated with Claude Code

The four queries behind the split page only ordered by message id for
members who view topics newest first. Otherwise the order was the
database's, which on PostgreSQL puts an edited post last, and with LIMIT
decides which posts land on which page.

Backport of SimpleMachines#9714.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
@live627 live627 added this to the 2.1.9 milestone Oct 8, 2026
@jdarwood007
jdarwood007 merged commit b8e02c2 into SimpleMachines:release-2.1 Oct 31, 2026
11 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.

3 participants