Skip to:
Content
Pages
Categories
Search
Top
Bottom

BUG: bbp_get_all_child_ids() grabs trashed posts

  • @appideasdotcom

    Participant

    The bbp_get_all_child_ids() function in bbpress/includes/common/functions.php is returning Trashed posts, which should objectively not be the case. There’s no world in which trashed posts should appear unless someone is intentionally digging in the trash.

    Line 1997 is currently this:
    $not_in = array( 'draft', 'future' );
    It should be this instead:
    $not_in = array( 'draft', 'future', 'trash' );

    I have tested that as a manual change, but obviously, this needs to be bbpress’ default behavior, not my locally-hacked override.

    Alternatively, you could add a third argument for overrides, but I think this is just an oversight.

    Thank you.

Viewing 5 replies - 1 through 5 (of 5 total)
  • @robin-w

    Moderator

    so can you say in what context this function is called?

    @appideasdotcom

    Participant

    Is that relevant? This is in custom child theme code. When I call bbp_get_all_child_ids() from code, either:
    1) I should not get ‘trash’ posts, or
    2) There needs to be a way to override post status for the query

    I haven’t traced the code through, but the ‘_bbp_total_topic_count’ post meta is getting decreased when the post is trashed. What’s visible and the count of what’s visible should definitely agree with each other.

    @robin-w

    Moderator

    I’m just a guy sat in his kitchen trying to help others, I am not paid to do this.

    It is entirely relevant in that they may well be a reason why trashed posts are added, without knowing when and why the function is called and how it is used, it is impossible to say that the code is wrong.

    I agree that a filter before that or variable passed would be helpful, but bbpress is not being actively worked on at the moment so it is unlikely that this would get updated.

    If you want to flag this, raise a ticket on https://bbpress.trac.wordpress.org/

    You might want to use bbp_get_public_child_ids or use the filter at the end of the function to as you say ‘override’ the setting, or if you are using this function directly, then simply create your own version of it.

    @robin-w

    Moderator

    just had a quick look, and for instance this function is used when moving a topic form one forum to another. The function makes sure that all replies (child ids of tne topic) are updated with the new forum_id in the reply postmeta, so that if restored later on, they remain correct.

    @appideasdotcom

    Participant

    Thank you for your time and input. It is very much appreciated!

    As a very long-time WordPress developer, I can state with confidence that a function that returns trashed posts by default is abnormal and unexpected, and not having a way to override such behavior is practically unheard-of in well-used, public plugins. I can’t think of another example.

    I’ve made attempts in the past to gain employment from WordPress/Automattic because of issues like this that I’d really like to dig into, not to mention some pieces of Jetpack that I’d love to tweak. I haven’t had any luck getting a response from them through their very odd job application process.

    That trac link you provided is probably the link I needed when I posted here instead. Thanks again.

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