WordPress.org

Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#17220 closed defect (bug) (fixed)

get_posts_by_author_sql() should use the post type object

Reported by: nacin Owned by:
Milestone: 3.2 Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: has-patch commit
Focuses: Cc:

Description

The filter there, pub_priv_sql_capability, is pretty useless, particularly since it doesn't receive any context. Suggesting we simply remove it.

Patch also adds a $post_type property to count_many_users_posts().

Attachments (2)

17220.diff (3.8 KB) - added by nacin 9 years ago.
17220.2.diff (3.8 KB) - added by PeteMall 9 years ago.
Fixed typos

Download all attachments as: .zip

Change History (7)

@nacin
9 years ago

#1 @nacin
9 years ago

  • Keywords has-patch added

Untested.

@PeteMall
9 years ago

Fixed typos

#2 @PeteMall
9 years ago

  • Keywords commit added

Tested with a custom column and using count_many_users_posts() with a custom post type.

#3 @nacin
9 years ago

Alternative for keeping the filter should be this:

if ( ! $cap = apply_filters( 'pub_priv_sql_capability', '' ) )
     $cap = $post_type_obj->cap->read_private_posts;

Rather than applying the filter over read_private_posts, given its historical usage.

#4 @nacin
9 years ago

Either way, we should also remove the various comments about pub_priv_sql_capability() in the phpdoc for get_private_posts_cap_sql(), which is where the filter was introduced in r5189.

#5 @nacin
9 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [17742]) Use the post type object in get_posts_by_author_sql() and add a post type parameter to count_many_users_posts(). The formerly somewhat useless and now totally useless pub_priv_sql_capability filter is considered deprecated. fixes #17220.

Note: See TracTickets for help on using tickets.