Skip to:
Content
Pages
Categories
Search
Top
Bottom

Empty “Topics started” and “Replies created”: hides private forums’ data


  • mfiguerasma
    Participant

    @mfiguerasma

    Hello,

    I’ve got a Participant roled user who can current_user_can( ‘read_private_forums’ ) but cannot current_user_can( ‘read_hidden_forums’ ).
    I’ve got three forums: two private and one hidden, so I expect to see the topics and replies he’s done in the two private forums, but I see the messages “You have not created any topics.” and “You have not replied to any topics.”

    While debugging, I’ve seen that the “_bbp_private_forums” option contains the two private forum IDs but the “_bbp_hidden_forums” option contains all the three forum IDs.
    I’ve executed the function bbp_repair_forum_visibility() to ensure my data is well retrieved from the database.
    While debugging the restore of these options, I can see that the “_bbp_hidden_forums” is built by the result of:
    $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’
    ) );
    This call triggers the filter “pre_get_posts”, calling the function bbp_pre_get_posts_normalize_forum_visibility( $posts_query = null )

    If I’m not wrong, this function builds an array whith the different post_status values to filter the query executed and stored in $hidden_forums IDs (and posts) values (or so)
    The problem is that in the $private_forums iteration it returns an array with only the “private” value, but in the $hidden_forums iteration it returns an array with two values: “hidden” and “private”

    The $private_forums iteration is used when a user cannot read private forums, but my user can.
    The $hidden_forums iteration is used when a user cannot read hidden forums, it’s my case, but I can read private forums and they are also filtered.

    I’m with WP 4.2.2, BP 2.2.1 and bbP 2.5.7

    Any idea? I’m very lost at this point…

    Thanks

Viewing 8 replies - 1 through 8 (of 8 total)

  • mfiguerasma
    Participant

    @mfiguerasma

    FYI I use the theme twentyfifteen, and changing the theme doesn’t solve the issue…


    mfiguerasma
    Participant

    @mfiguerasma

    I’ve done a new, clean WP installation.
    Only WP, BP and bbP, all the last versions.
    One admin (keymaster) user, one regular (participant) user.
    Two forums: public one and private one.
    The participant creates a topic and a reply in both of the forums.
    Go to his own activity page, Forums section, and only the public forum is displayed.
    I assume this is a bug, it’s a nosense that a user cannot see his own created data in his own activity page.
    If I only work with private and hidden forums, this section will always be empty!
    I’m not able to understand this behaviour…


    Robkk
    Moderator

    @robkk

    Thanks for debugging and creating this ticket, sorry for not responding earlier though.

    https://bbpress.trac.wordpress.org/ticket/2829

    I will contact the devs about this to see what they think.


    Brandon Allen
    Participant

    @thebrandonallen

    I can’t reproduce this behavior on bbPress 2.5.8 or trunk using the default WordPress themes. Topics and replies in private forums are listed. Are you using a custom theme? Are you running any plugins that effect user profiles? Are you running BuddyPress?


    mfiguerasma
    Participant

    @mfiguerasma

    I’m using TwentyFifteen theme, and the versions:
    WordPress 4.2.2
    BuddyPress 2.2.1
    BBPress 2.5.7


    PieterPieterDrum
    Participant

    @pieterpieterdrum

    Hello, I have the same issue.
    I work with BuddyPress, bbPress and a them from Nitty Gritty Klein (Music theme).
    This theme creates groups. Forums can be allocated to groups.
    A member of a group can create a topic and he can reply. No problem.
    But in the menu there is an option forums, you can see your own contributions.
    Logged in, a member sees ‘You have not created any topics.’ But he has.
    Going to the forum via the group, then he can see his own topics etc. No problems.

    I have repaired with tools/forums.
    I have 3 private forums, and 1 public group and 2 private groups.
    There is something wrong with the conflict between private and public??


    mlwilkerson
    Participant

    @mlwilkerson

    I’m seeing the same thing as originally reported by @mfiguerasma.

    I first noticed it when my non-admin user (TestUser) *suddenly* could no longer see a topic that he had formerly been able to see. In my case, I am using sub-forums. (See: https://bbpress.trac.wordpress.org/ticket/2191#comment:17 )

    I have a BP Group called GroupH.
    The group forum root is a type=category group called “Group Forums”
    Subforum1-GroupH is under the forum “GroupH”.

    GroupH is the group forum, i.e the one you see in a the drop-down in the settings where you select which forum is associated with the BP Group.

    So, it’s:

    Group Forums
    GroupH
    Subforum1-GroupH
    Topic1-Subforum1-GroupH

    All of the forums and subforums have a Visibility setting of Private (in the admin settings screens).

    So Topic1-Subforum1-GroupH was accessible by my TestUser one minute and then wasn’t the next minute. I knew that I hadn’t changed the visibility settings on my forums or anything else, but I realized that what I had done (thinking it was merely “for good measure”) was to run:
    Tools->bbPress->Recalculate private and hidden forums

    I recreated my original scenario, verified that TestUser could access Topic1-Subforum1-GroupH, and then used Updraft to take snapshots of my database before running “Recalculate private and hidden forums” calculate again. Sure enough, after that “repair”, it was broken again.

    So I debugged it. This repair tool kicks off bbp_repair_forum_visibility() which updates two options in the options table:
    _bbp_private_forums
    _bbp_hidden_forums

    These are pre-calculated, cached, lists of forums.

    If the forum_id for GroupH appears in _bbp_hidden_forums, then TestUser won’t be able to access Topic1-Subforum1-GroupH. Before running this “repair”, the forum_id for GroupH does not appear in that list. After the repair it does.

    So, how is the forum_id for GroupH getting into this list of hidden forums when the post_status on the forum is most definitely private? (Verified by looking at its row in the posts table)

    It’s getting there precisely by the means @mfiguerasma showed.

    When the query is being run to get a list of all “hidden” forums, in order to create _bbp_hidden_forums, it invokes the pre_get_posts filter. bbPress uses that filter bbp_pre_get_posts_normalize_forum_visibility() to change the query_vars.

    Notice what’s happening here:

    (1) The WP_Query is saying “I am trying to find a list of *hidden* forums” (I have my own reasons for why I want a list of hidden forums.)

    (2) But bbp_pre_get_posts_normalize_forum_visibility() seems to be second-guessing. I receives query_vars with post_type=hidden, but then the way its logic works is to say: “What are various post statuses that this user has permission to see. Ah, this user can see both hidden and private ones, so I’ll update the query_vars to include post_types of both hidden and private.”

    I think the logic of bbp_pre_get_posts_normalize_forum_visibility() is exactly backwards. It’s trying to include all of the post_types that the user can access. But that’s not why it has been invoked. It’s been invoked in the process of simply creating a list of hidden forums for _bbp_hidden_forums and its messing that up by including the private post_status.

    (3) So what the WP_Query gets back is a list of forum_ids for all hidden *and private* groups. And that’s the list that ultimately gets stored in _bbp_hidden_forums.

    So this “repair” actually breaks my forums.

    If you simply remove this bbPress filter before doing the repair, it seems to produce the correct result. My TestUser can access Topic1-Subforum1-GroupH both before and after the repair when we remove the filter:
    remove_action(‘pre_get_posts’,’bbp_pre_get_posts_normalize_forum_visibility’,4);


    mlwilkerson
    Participant

    @mlwilkerson

    After doing some more work on this, I think that while the visibility of my topic in the subforum is indeed broken after the Subforum’s ID is placed in the _bbp_hidden_forums option, that is only a symptom and not a cause.

    I think that the fundamental assumptions of this version of bbPress/BuddyPress preclude the use of Subforums. And evidence of this is that visibility sensitive areas of the code like this just come up with the wrong answer when subforums are involved.

    So for me, I think I’m going to stop trying to make subforums work until the core code changes to better support them.

Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.
Skip to toolbar