Skip to content

[3.0] Lists tied moderation log entries in a defined order - #9726

Merged
jdarwood007 merged 1 commit into
SimpleMachines:release-3.0from
albertlast:3.0/modlog-order
Oct 4, 2026
Merged

jdarwood007 merged 1 commit into
SimpleMachines:release-3.0from
albertlast:3.0/modlog-order

Conversation

@albertlast

Copy link
Copy Markdown
Collaborator

Description

The moderation log and the administration log sort by one column and leave the order of tied entries to the database. Every one of their columns can tie: time for entries logged in the same second (any request that logs more than one entry produces those), and action, moderator, position and IP for most of the log.

The two engines disagree about ties:

  • MySQL lists entries from the same second oldest first, although the default view is newest first. So within any one second, the log reads backwards.
  • PostgreSQL lists them newest first until one of the rows is rewritten, and then the order flips. On a paginated list, the entries at a page boundary can then appear on both pages or on neither.

I found this through the template snapshot suite (#9712). On MySQL, the admin log page listed a different set of entries from one run to the next, because each run logs a category and several boards within the same second.

The fix is in Logs::list_getModLogEntries(), which both lists use (the log page and ReportedContent). Tied entries fall back to lm.id_action, the order they were logged in. The tiebreaker takes its direction from the column: when the column sorts descending, id_action does too. So reversing a column gives the exact mirror of the list. Putting it in the query function, not in the ten column definitions, also covers columns a mod adds through integrate_ hooks.

Tests

tests/Integration/ModLogTest.php logs two identical entries at the same time and lists them under each sort the two lists offer.

Without the fix, 4 of the 8 cases fail on each engine, and they are different cases on each:

fails without the fix
MySQL time newest first (the default view), action reversed, moderator reversed, position reversed
PostgreSQL time oldest first, action, moderator, IP

With the fix, all 8 pass on both engines, three runs each. The full unit and integration suite also passes on both.

Issues References (Fixes|Related|Closes)

Related: #9712, #9721 and #9722 fix the same kind of problem, a sort with no tiebreaker, in other places.

🤖 Generated with Claude Code

Every column the moderation and administration logs sort by can tie, the
time column included for entries logged in the same second, and the query
left the order of tied entries to the database. The engines disagree: MySQL
listed them oldest first in the default newest-first view, and PostgreSQL's
order changes when a row is rewritten. Ties now fall back to the order the
entries were logged, reversed along with the column.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
@jdarwood007 jdarwood007 modified the milestones: 2.1.9, 3.0 Alpha 5 Oct 4, 2026
@jdarwood007
jdarwood007 merged commit a17a03f into SimpleMachines:release-3.0 Oct 4, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants