Opened 10 months ago

Closed 7 months ago

#21431 closed enhancement (fixed)

Allow count_many_users_posts() to count only public posts

Reported by: ryan Owned by: nacin
Priority: normal Milestone: 3.5
Component: Users Version: 3.4.1
Severity: normal Keywords: has-patch do-not-punt commit
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 10 months ago.
Core patch plus corresponding changes to a plugin to provide context
21431.2.diff (3.0 KB) - added by westi 7 months ago.
Updates diff against current trunk

Download all attachments as: .zip

Change History (9)

ryan10 months ago

Core patch plus corresponding changes to a plugin to provide context

Patch courtesy of Barry.

  • Description modified (diff)
  • Keywords has-patch added
  • Keywords do-not-punt added

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

westi7 months ago

Updates diff against current trunk

  • Keywords commit added
  • 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.