Opened 2 years ago

Closed 2 years ago

#17220 closed defect (bug) (fixed)

get_posts_by_author_sql() should use the post type object

Reported by: nacin Owned by:
Priority: normal Milestone: 3.2
Component: Post Types Version:
Severity: normal Keywords: has-patch commit
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 2 years ago.
17220.2.diff (3.8 KB) - added by PeteMall 2 years ago.
Fixed typos

Download all attachments as: .zip

Change History (7)

nacin2 years ago

  • Keywords has-patch added

Untested.

Fixed typos

  • Keywords commit added

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

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.

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.

  • 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.