Skip to content

[3.0] Give each post one quick-moderation checkbox, and no empty submit - #9478

Open
albertlast wants to merge 2 commits into
SimpleMachines:release-3.0from
albertlast:3.0/topic-quickmod-checkboxes
Open

[3.0] Give each post one quick-moderation checkbox, and no empty submit#9478
albertlast wants to merge 2 commits into
SimpleMachines:release-3.0from
albertlast:3.0/topic-quickmod-checkboxes

Conversation

@albertlast

Copy link
Copy Markdown
Collaborator

Description

With Show quick-moderation as: checkboxes turned on in a member's look-and-layout options, the topic display has three related problems. All of them come from InTopicModeration in topic.js.

Two checkboxes beside every post. Display.template.php constructs the widget twice - once for moderationbuttons and once for moderationbuttons_mobile - and both instances run the same loop appending a fresh msgs[] checkbox to the same in_topic_mod_check_<id> container. Measured on a 15-post page: 15 containers, 2 checkboxes each. Ticking one also only updates its own instance's counter, so the other strip's button reads [0].

The buttons work with nothing selected. In 2.1 the Remove/Restore/Split buttons were created inside handleClick(), guarded by bButtonsShown, so they did not exist until something was ticked. 3.0 moved that block into init() and dropped the guard - this.bButtonsShown is still assigned in the constructor and now never read. The buttons therefore appear at page load, with no count, and pressing one submits quickModForm with no msgs[]:

2: Undefined array key "msgs"
array_map(): Argument #2 ($array) must be of type array, null given

and the member gets a blank page. QuickModerationInTopic::__construct() reads $_REQUEST['msgs'] unguarded; all three sub-actions then need a non-empty list anyway (split() takes min() of it, the other two hand it to an {array_int:...}), so the action now redirects back to the topic when given nothing.

A stray variable. The same move left the else branch in init() assigning to oNewDiv, which is not declared anywhere - a ReferenceError if the button strip's display element is ever missing.

How to test

Profile → Look and Layout → Show quick-moderation as: Checkboxes. Open a topic.

  • Before: two checkboxes per post; "Remove selected" and "Split selected" visible immediately; clicking one gives a blank page and the errors above in smf_log_errors.
  • After: one checkbox per post; the buttons are hidden until something is ticked and then read [1], [2], … on both strips; the split-selected flow completes with an empty error log.

Issues References (Fixes|Related|Closes)

Found while sweeping the topic display for the #7933 split.

A topic draws two of these strips, one for the page and one for the mobile
menu, and both instances append their own checkbox to the same container.
So every post carried two of them side by side, and ticking one left the
other strip's count wrong. Reuse whatever checkbox is already in the
container and just listen to it as well.

2.1 built the Remove/Restore/Split buttons on the first checkbox click.
3.0 moved that block into init(), which left them on screen from page
load, with nothing selected and no count. Pressing one then submitted the
form with no msgs[] at all, and quickmod2 read $_REQUEST['msgs']
unguarded: a blank page, an undefined key and array_map() on null. Show
the buttons from the same place that already counts, so they start hidden,
and let the action redirect back to the topic if it is handed nothing.

The move also left the else branch assigning to oNewDiv, which is not
declared anywhere.

Signed-off-by: Mathias Papenbrock <mathiaspapealbert@hotmail.com>
Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
@albertlast albertlast mentioned this pull request Aug 9, 2026
Comment thread Themes/default/scripts/topic.js Outdated
Review asked for the selector to come out of the loop. The scoped call
could not move as it stood, since the container it looks inside is a
different element on every pass, so this queries the document once and
indexes what it finds by the message id each checkbox carries. This file
is the only thing that emits a msgs[] input, so an unscoped query has
nothing else to pick up.

Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
@jdarwood007 jdarwood007 added this to the 3.0 Alpha 6 milestone Aug 10, 2026
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.

3 participants