Opened 11 years ago
Closed 11 years ago
#2512 closed defect (bug) (fixed)
bbp_admin_repair_forum_visibility repair tool breaks private and hidden forum visibility
Reported by: | netweb | Owned by: | netweb |
---|---|---|---|
Milestone: | 2.6 | Priority: | normal |
Severity: | major | Version: | 2.5 |
Component: | Tools | Keywords: | |
Cc: |
Description
Running the bbp_admin_repair_forum_visibility repair tool breaks forum visibility.
Each private and hidden forum are assigned both _bbp_hidden_forums
and _bbp_hidden_forums
statuses.
Repro:
- Create a hidden forum (post_id = 95887)
- Create a private forum (post_id = 95889)
- Run bbp_admin_repair_forum_visibility repair tool
Postmeta Actual Results:
_bbp_hidden_forums | a:2:{i:0;s:5:"95889";i:1;s:5:"95887";} | yes |
_bbp_private_forums | a:2:{i:0;s:5:"95889";i:1;s:5:"95887";} | yes |
Postmeta Expected Results:
_bbp_hidden_forums | a:1:{i:1;s:5:"95887";} | yes |
_bbp_private_forums | a:1:{i:0;s:5:"95889";} | yes |
The repair tool bbp_admin_repair_forum_visibility
(/includes/forums/functions.php#L927) runs the follow two WP_Query
queries:
$private_forums = new WP_Query( array(
'suppress_filters' => true,
'nopaging' => true,
'post_type' => bbp_get_forum_post_type(),
'post_status' => bbp_get_private_status_id(),
'fields' => 'ids',
'cache_results' => false
) );
$hidden_forums = new WP_Query( array(
'suppress_filters' => true,
'nopaging' => true,
'post_type' => bbp_get_forum_post_type(),
'post_status' => bbp_get_hidden_status_id(),
'fields' => 'ids'
) );
For which the query result for $private_forums
is:
WP_Query Object
(
[query] => Array
(
[suppress_filters] => 1
[nopaging] => 1
[post_type] => forum
[post_status] => private
[fields] => ids
[cache_results] =>
)
[query_vars] => Array
(
[suppress_filters] => 1
[nopaging] => 1
[post_type] => forum
[post_status] => Array
(
[0] => private
[2] => hidden
)
[fields] => ids
SELECT wp_posts.ID FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'forum' AND (wp_posts.post_status = 'hidden' OR wp_posts.post_status = 'private') ORDER BY wp_posts.post_date DESC
For which the query result for $hidden_forums
is:
WP_Query Object
(
[query] => Array
(
[suppress_filters] => 1
[nopaging] => 1
[post_type] => forum
[post_status] => hidden
[fields] => ids
)
[query_vars] => Array
(
[suppress_filters] => 1
[nopaging] => 1
[post_type] => forum
[post_status] => Array
(
[0] => hidden
[1] => private
)
[fields] => ids
SELECT wp_posts.ID FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'forum' AND (wp_posts.post_status = 'hidden' OR wp_posts.post_status = 'private') ORDER BY wp_posts.post_date DESC
Thus when update_option
is executed both private and hidden forums BOTH get assigned a _bbp_private_forums
and _bbp_hidden_forums
value in wp_postmeta
Workaround:
- Don't run the bbp_admin_repair_forum_visibility repair tool
Via the backend forum edit admin:
- Change the forum visibility from eg. private to public and save
- Change the forum visibility back to the original private status and save
Attachments (1)
Change History (8)
#2
@
11 years ago
Gut tells me there's a filter adding the additional post statuses in that needs to be unhooked. Though, wonder why it's not obeying suppress_filters
.
#3
follow-up:
↓ 5
@
11 years ago
This appears to be related to bbp_pre_get_posts_normalize_forum_visibility()
added with pre_get_posts
https://bbpress.trac.wordpress.org/browser/trunk/includes/core/actions.php#L152
Since, pre_get_posts
is an action, suppress_filters
has no effect. Attached patch should fix the issue.
#4
@
11 years ago
- Component changed from Forums to Tools
- Keywords commit added; needs-patch removed
- Milestone changed from Awaiting Review to 2.6
- Severity changed from normal to major
Perfect. Run it.
#5
in reply to:
↑ 3
@
11 years ago
- Component changed from Tools to Forums
- Keywords has-patch added; commit removed
- Milestone changed from 2.6 to Awaiting Review
- Severity changed from major to normal
Replying to thebrandonallen:
This appears to be related to
bbp_pre_get_posts_normalize_forum_visibility()
added withpre_get_posts
. Since,pre_get_posts
is an action,suppress_filters
has no effect. Attached patch should fix the issue.
Yep, that's it. Thanks for the patch, works perfectly.
Oops, second line above should read:
Each private and hidden forum are assigned both
_bbp_private_forums
and_bbp_hidden_forums
statuses.