Skip to:
Content

bbPress.org

Opened 6 weeks ago

Closed 4 weeks ago

Last modified 3 weeks ago

#3724 closed regression (fixed)

Reply forum repair control no longer saves changes

Reported by: johnjamesjacoby Owned by: johnjamesjacoby
Priority: normal Milestone: 2.6.21
Component: General - Administration Version: trunk
Severity: normal Keywords: has-unit-tests
Cc:

Description

bbp_reply_metabox() retains a Forum selector intended to repair replies whose stored forum metadata differs from their topic's forum.

Since [7687], BBP_Replies_Admin::save_meta_boxes() ignores the submitted bbp_forum_id and always derives the forum from the selected topic. When the repair control appears for mismatched legacy metadata, choosing a forum and saving therefore discards that choice.

The administration UI should either remove the obsolete repair control, or restore a validated way to repair reply forum metadata while preserving the destination permission checks and count synchronization added in [7687].

This regression was introduced in trunk and is not present in the 2.6 branch.

Attachments (1)

3724.01.patch​ (6.5 KB ) - added by softglaze 4 weeks ago.
Remove the ignored reply Forum control, with unit tests.

Download all attachments as: .zip

Change History (8)

@softglaze
4 weeks ago

Remove the ignored reply Forum control, with unit tests.

#1 @softglaze
4 weeks ago

3724.01.patch takes the first option in the description: it removes the Forum control from bbp_reply_metabox(), with the two variables only that control used. It also adds a line to CHANGELOG.md.

Cause: since r7687, BBP_Replies_Admin::save_meta_boxes() takes the topic from the reply (or from an accepted move) and the forum from bbp_get_topic_forum_id() of that topic. It no longer reads $_POST['bbp_forum_id'], so the forum chosen in the control is discarded.

Why I removed it instead of making it save again:

  • r5510 (#2270) limited the control to mismatches, so it could repair them but not create new ones. The value that repairs a mismatch is the forum of the topic.
  • Saving the reply already stores that value: bbp_update_reply() writes the topic's forum to the reply's _bbp_forum_id. So any save of a mismatched reply repairs it. For the whole site, the "Recalculate parent forum for each topic and reply" repair tool resets it from each reply's topic.
  • Any other choice would create a mismatch again, and would need its own destination checks and forum count updates next to the ones added in r7687.

When the control appears: bbp_get_reply_forum_id() and bbp_get_topic_forum_id() both return the topic's post_parent first. So the control only shows when the topic has no parent forum and the reply and topic _bbp_forum_id values differ.

The patch adds 2 tests:

  • test_reply_metabox_omits_forum_control_for_mismatched_forum_meta builds that case and checks that the reply metabox has no bbp_forum_id select. It fails on trunk.
  • test_reply_save_repairs_mismatched_forum_meta_from_topic saves the same kind of reply through the editor, with bbp_forum_id set to the reply's stored forum (what the control submitted), and checks that the reply gets the forum of its topic. It passes on trunk too: it covers the repair that replaces the control.

Results with bbPress trunk (r8129), WordPress 7.2-beta1, PHP 8.3.32. The first two runs use --filter 'test_reply_metabox|test_reply_save_repairs_mismatched_forum_meta_from_topic' (the 2 new tests and the existing reply metabox test).

Run Result
Trunk 1 failure: test_reply_metabox_omits_forum_control_for_mismatched_forum_meta, the Forum select is shown
Patch OK (3 tests, 15 assertions)
Patch, full suite 2400 tests, 10923 assertions, 31 skipped, 1 failure: test_bbp_set_current_anonymous_user_data

That failure is a cURL timeout to the local server the test starts. It fails the same way on trunk in my environment and is not related to the patch.

About the 2.6 branch: r7688 merged the same save_meta_boxes() change into branches/2.6, and it shipped in 2.6.19 and 2.6.20 with the control still in the metabox. So the control is ignored there too. The src part of the patch applies to branches/2.6 as is. tests/phpunit/testcases/admin/metaboxes.php does not exist there.

Thanks @johnjamesjacoby for the report.

#2 @johnjamesjacoby
4 weeks ago

  • Owner set to johnjamesjacoby
  • Resolution → fixed
  • Status new → closed

In 8136:

Replies: Sync Forum and Reply To with Topic.

Show the selected topic's forum in a read-only dropdown and stage its Reply To choices when an administrator changes Topic. Preview the destination with the same move permissions used on save. Continue deriving the forum from the accepted topic and validating the parent reply on Update, which repairs stale forum metadata without writing during the preview.

In trunk, for 2.7.

Props softglaze.
Fixes #3724.

#3 @johnjamesjacoby
4 weeks ago

In 8137:

Replies: Sync Forum and Reply To with Topic.

Show the selected topic's forum in a read-only dropdown and stage its Reply To choices when an administrator changes Topic. Preview the destination with the same move permissions used on save. Continue deriving the forum from the accepted topic and validating the parent reply on Update, which repairs stale forum metadata without writing during the preview.

In branches/2.6, for 2.6.21.

Props softglaze.
Fixes #3724.

#4 @johnjamesjacoby
4 weeks ago

  • Keywords has-unit-tests added; needs-unit-tests removed

#5 @johnjamesjacoby
4 weeks ago

In 8138:

Tests: Cover reply topic/forum AJAX previews.

Exercise successful destination previews without saving, denied destination permissions, invalid reply and topic IDs, non-POST requests, and nonce rejection. Confirm rejected previews do not expose destination forum details.

In trunk, for 2.7.

See #3724.

#6 @johnjamesjacoby
4 weeks ago

In 8139:

Tests: Cover reply topic/forum AJAX previews.

Exercise successful destination previews without saving, denied destination permissions, invalid reply and topic IDs, non-POST requests, and nonce rejection. Confirm rejected previews do not expose destination forum details.

In branches/2.6, for 2.6.21.

See #3724.

#7 @johnjamesjacoby
3 weeks ago

  • Milestone 2.7 → 2.6.21
Note: See TracTickets for help on using tickets.