WordPress.org

Make WordPress Core

Opened 8 months ago

Last modified 8 months ago

#45640 new enhancement

get_blogs_of_user improvements

Reported by: maniu Owned by:
Milestone: Awaiting Review Priority: normal
Severity: minor Version: 3.0
Component: Networks and Sites Keywords: needs-unit-tests has-patch
Focuses: multisite Cc:

Description

get_blogs_of_user function is often pulling more data than it needs. This often won't cause any issues but in some cases when user is attached to big number of blogs, it may lead to out of memory error.

Attached patch has changes that can lead to more improvements like pagination for "My Sites" admin page, limitation of listed sites in admin bar and on "access denied" page.

Attachments (2)

get_blogs_of_users.diff (16.0 KB) - added by maniu 8 months ago.
get_blogs_of_user improvements
get_blogs_of_users_new.patch (15.7 KB) - added by maniu 4 months ago.
modified version that does not include tweaks to $all parameters as they are confusing and not crucial for performance improvement.

Download all attachments as: .zip

Change History (4)

@maniu
8 months ago

get_blogs_of_user improvements

#1 @earnjam
8 months ago

  • Keywords needs-unit-tests added
  • Version changed from trunk to 3.0

Hi @maniu, thanks for your ticket! There are definitely improvements to be made around querying sites across a network and improvements to get_blogs_of_user() are likely part of the overall multisite roadmap.

We'll probably pick up more of those discussions as we resume our weekly meetings in Slack in the new year and post 5.0.

Regarding the specific patch here, I wonder if it might make more sense to keep the second parameter as the current boolean value, and instead checking for some type of all_ids value in the $args array.

Mixing the type (bool, string) and usage (manipulating the returned list of sites vs returned fields) of a single parameter feels like it could easily lead to confusion.

#2 @maniu
8 months ago

  • Keywords changed from has-patch needs-unit-tests to needs-unit-tests has-patch

Hey @earnjam, yeah I think you are right. I could have avoided all_ids as having $all = true together with $args = array( 'fields' => 'ids' ) can cover it. I will work on another patch. Thanks!

@maniu
4 months ago

modified version that does not include tweaks to $all parameters as they are confusing and not crucial for performance improvement.

Note: See TracTickets for help on using tickets.