Make WordPress Core

#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:

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 21 months ago.
Core patch plus corresponding changes to a plugin to provide context
21431.2.diff (3.0 KB) - added by westi 18 months ago.
Updates diff against current trunk

Download all attachments as: .zip

Change History (9)

ryan21 months ago

Core patch plus corresponding changes to a plugin to provide context

comment:1 ryan21 months ago

Patch courtesy of Barry.

comment:2 ryan21 months ago

  • Description modified (diff)

comment:3 wonderboymusic21 months ago

  • Keywords has-patch added

comment:4 nacin19 months ago

  • Keywords do-not-punt added

comment:5 westi18 months ago

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

westi18 months ago

Updates diff against current trunk

comment:6 westi18 months ago

  • Keywords commit added

comment:7 nacin18 months 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.