#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)
Change History (8)
#1
@
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_metabuilds that case and checks that the reply metabox has nobbp_forum_idselect. It fails on trunk.test_reply_save_repairs_mismatched_forum_meta_from_topicsaves the same kind of reply through the editor, withbbp_forum_idset 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.
Remove the ignored reply Forum control, with unit tests.