WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#21431 closed enhancement (fixed)

Allow count_many_users_posts() to count only public posts

Reported by: ryan Owned by: nacin
Milestone: 3.5 Priority: normal
Severity: normal Version: 3.4.1
Component: Users Keywords: has-patch do-not-punt commit
Focuses: Cc:
PR Number:

Description (last modified by ryan)

count_many_users_posts() calls get_posts_by_author_sql() which contains some cap checks. This makes the output dependent on the current user and thus not very cacheable. Let's add a means of counting only public posts that skips the cap and current user checks.

Attachments (2)

21431.diff (5.2 KB) - added by ryan 7 years ago.
Core patch plus corresponding changes to a plugin to provide context
21431.2.diff (3.0 KB) - added by westi 7 years ago.
Updates diff against current trunk

Download all attachments as: .zip

Change History (9)

@ryan
7 years ago

Core patch plus corresponding changes to a plugin to provide context

#1 @ryan
7 years ago

Patch courtesy of Barry.

#2 @ryan
7 years ago

  • Description modified (diff)

#3 @wonderboymusic
7 years ago

  • Keywords has-patch added

#4 @nacin
7 years ago

  • Keywords do-not-punt added

#5 @westi
7 years ago

I've written some unit tests for the change in [UT1097]

@westi
7 years ago

Updates diff against current trunk

#6 @westi
7 years ago

  • Keywords commit added

#7 @nacin
7 years ago

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

In 22386:

Add a $public_only argument to count_many_users_posts() and get_posts_by_author_sql(). Defaults to false, and allows the counts to be returned for only public posts. props ryan, westi. fixes #21431.

Note: See TracTickets for help on using tickets.