Skip to:
Content

bbPress.org

Opened 14 years ago

Closed 14 years ago

Last modified 3 years ago

#2059 closed defect (bug) (fixed)

bbp_delete_topic is not deleting the child replies

Reported by: MZAWeb Owned by: MZAWeb
Priority: normal Milestone: 2.3
Component: Tools - Code Improvements Version: 2.2
Severity: major Keywords: has-patch commit
Cc: wordpress@…

Description

The query generated by the WP_Query in there looks like:

SELECT   wp_posts.ID, wp_posts.post_parent FROM wp_posts  WHERE 1=1  AND wp_posts.post_parent = 93  AND wp_posts.post_type = 'reply' AND (wp_posts.post_status <> 'trash' AND wp_posts.post_status <> 'auto-draft' AND wp_posts.post_status <> 'spam' AND wp_posts.post_status <> 'orphan' AND wp_posts.post_status <> 'hidden')  ORDER BY wp_posts.post_date DESC 

It seems the post_status => any is getting lost somehow.

I'm on WordPress 3.5 trunk

Attachments (2)

2059.diff (1.4 KB ) - added by MZAWeb 14 years ago.
2059.2.diff (1.4 KB ) - added by MZAWeb 14 years ago.

Download all attachments as: .zip

Change History (13)

#1 @MZAWeb
14 years ago

  • Cc wordpress@… added

#2 @MZAWeb
14 years ago

Interesting! The post_status=>any won't work for us. get_post excludes all the stati that has 'exclude_from_search':

if ( ! empty( $q['post_status'] ) ) {

... more code ...

if ( in_array('any', $q_status) ) {
				foreach ( get_post_stati( array('exclude_from_search' => true) ) as $status )
					$e_status[] = "$wpdb->posts.post_status <> '$status'";

... more code ...

} elseif ( !$this->is_singular ) {

... more code ...

if ( $this->is_admin ) {
				// Add protected states that should show in the admin all list.
				$admin_all_states = get_post_stati( array('protected' => true, 'show_in_admin_all_list' => true) );
				foreach ( (array) $admin_all_states as $state )
					$where .= " OR $wpdb->posts.post_status = '$state'";
			}

... more code ...

}

so, the $this->is_admin is not kicking in when post_status=>any

#3 @johnjamesjacoby
14 years ago

  • Component TopicsCode Improvement
  • Keywords needs-patch added
  • Milestone Awaiting Review2.3

Looks like the safest thing we can do here is include an array of every single post status that's possible for these to have. Being explicit appears to override any of the additional checks that WP_Query::get_posts() does.

I see two usages of post_status 'any' that would need this.

Last edited 14 years ago by johnjamesjacoby (previous) (diff)

#4 @MZAWeb
14 years ago

Makes sense. I'll take a pass next week. So,

[publish] => publish
[future] => future
[draft] => draft
[pending] => pending
[private] => private
[trash] => trash
[auto-draft] => auto-draft
[inherit] => inherit

Probably all, right?

Last edited 14 years ago by MZAWeb (previous) (diff)

#5 @MZAWeb
14 years ago

  • Owner set to MZAWeb
  • Status newassigned

@MZAWeb
14 years ago

#6 @MZAWeb
14 years ago

  • Keywords has-patch added; needs-patch removed

Attached a fix.

#7 @johnjamesjacoby
14 years ago

Don't forget the bbPress statuses: closed, spam, etc...

#8 @MZAWeb
14 years ago

get_post_stati returns the bbp stati too:

Array
(
    [0] => publish
    [1] => future
    [2] => draft
    [3] => pending
    [4] => private
    [5] => trash
    [6] => auto-draft
    [7] => inherit
    [8] => closed
    [9] => spam
    [10] => orphan
    [11] => hidden
)

@MZAWeb
14 years ago

#9 @johnjamesjacoby
14 years ago

  • Keywords commit added

Nice.

#10 @johnjamesjacoby
14 years ago

  • Resolutionfixed
  • Status assignedclosed

(In [4524]) Deleting:

  • When deleting a forum or topic, make sure all child content is deleted also.
  • Also add some inline doc, and unset query variables, and clean up messy inline comparisons.
  • Props MZAWeb.
  • Fixes #2059.

#11 @johnjamesjacoby
14 years ago

(In [4525]) Supplemental update to bbp_trash_forum_topics(). See #2059.

Note: See TracTickets for help on using tickets.