[wp-trac] [WordPress Trac] #31746: get_blogs_of_user() can be very slow when a user is a member of thousands of sites

WordPress Trac noreply at wordpress.org
Tue Mar 24 02:19:47 UTC 2015


#31746: get_blogs_of_user() can be very slow when a user is a member of thousands
of sites
--------------------------+-----------------------------
 Reporter:  jtsternberg   |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Users         |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:  multisite     |
--------------------------+-----------------------------
 When a user belongs to thousands of sites, the array of `$blogs` can
 become rather large. Considering get_blogs_of_user is called in many
 places on every page-load when a user is logged in, Some optimization
 should happen here. Not counting the multisite admin pages,
 `get_blogs_of_user()` is called from the functions
 `is_user_member_of_blog()`, `get_dashboard_url()`, and
 `WP_Admin_Bar::initialize()`. I propose the results of the function to at
 least be stored to a static variable to prevent multiple lookups to the
 same information. I also propose that a pre-fetch filter
 (pre_get_blogs_of_user ?) be added so that a plugin can override that
 information and provide something more efficient if the need arises.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/31746>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list