Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#15715 closed enhancement (invalid)

Add page load caching to get_users_of_blog()

Reported by: yoavf Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0.2
Component: Users Keywords: needs-patch
Focuses: Cc:

Description (last modified by yoavf)

Theme authors often use get_users_of_blog() in various area to style/present blog authors. Unfortunately, the query resulting from this function isn't cached, and can be quite expensive in a large multisite environment.

Proposed patch adds simple caching to get_users_of_blog()

Attachments (1)

cache_get_users_of_blog.diff (541 bytes) - added by yoavf 4 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 @yoavf4 years ago

  • Description modified (diff)

comment:2 @Denis-de-Bernardy4 years ago

  • Keywords needs-patch added; has-patch removed
  • Milestone changed from Awaiting Review to Future Release
  • Version set to 3.0.2

The cache also needs to be invalidated.

comment:3 @westi4 years ago

This cache should only last for the page load so doesn't need invalidation.

It just needs registering as non-persistent in the right places with wp_cache_add_non_persistent_groups

comment:4 @westi4 years ago

Probably should just be in the counts group in fact

comment:5 @yoavf4 years ago

Rethinking this:

get_users_of_blog() returns the complete users objects for every users, yet scenarios where only user ids/nicenames/email are required, are the reason I opened this ticket in the first place.

A better solution would probably be to have a function that can return specific columns of the user table.
Does that make sense?

comment:6 @yoavf4 years ago

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

Irrelevant, get_users_of_blog() has been deprecated in favor of get_users()
See #15053

comment:7 @ocean904 years ago

  • Milestone Future Release deleted
Note: See TracTickets for help on using tickets.